@@ -22,13 +22,13 @@ public class CosmosTestContainer : ITestContainer<string, TestCosmosItem>,
22
22
private CosmosDatabase _database ;
23
23
private DockerClient _dockerClient ;
24
24
private const string containerName = "cosmosContainer" ;
25
- private ushort privatePort = 8081 ;
25
+ private const ushort privatePort = 8081 ;
26
26
private bool containerExsist = false ;
27
27
private string containerId ;
28
28
29
29
public CosmosTestContainer ( )
30
30
{
31
- _cosmosTestContainer = new TestcontainersBuilder < TestcontainersContainer > ( )
31
+ /* _cosmosTestContainer = new TestcontainersBuilder<TestcontainersContainer>()
32
32
.WithImage("mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator")
33
33
.WithName(containerName)
34
34
.WithExposedPort(8081)
@@ -50,7 +50,7 @@ public CosmosTestContainer()
50
50
.UntilPortIsAvailable(privatePort))
51
51
.Build();
52
52
53
- _dockerClient = new DockerClientConfiguration ( ) . CreateClient ( ) ;
53
+ _dockerClient = new DockerClientConfiguration().CreateClient();*/
54
54
}
55
55
56
56
public IDatabaseCollection < string , TestCosmosItem > Collection =>
@@ -63,7 +63,7 @@ public string GenerateId()
63
63
64
64
public async Task InitializeAsync ( )
65
65
{
66
- ushort publicPort = privatePort ;
66
+ /* ushort publicPort = privatePort;
67
67
68
68
try
69
69
{
@@ -76,25 +76,24 @@ public async Task InitializeAsync()
76
76
containerExsist = true;
77
77
}
78
78
79
- /* if (!containerExsist)
79
+ if (!containerExsist)
80
80
{
81
81
publicPort = _cosmosTestContainer.GetMappedPublicPort(privatePort);
82
82
containerId = _cosmosTestContainer.Id;
83
83
}
84
84
else
85
- {*/
85
+ {
86
86
var listContainers = await _dockerClient.Containers.ListContainersAsync(new ContainersListParameters());
87
87
88
88
ContainerListResponse containerListResponse = listContainers.FirstOrDefault(container => container.Names.Contains($"/{containerName}"));
89
89
90
90
if (containerListResponse != null)
91
91
{
92
- privatePort = containerListResponse . Ports . LastOrDefault ( ) . PrivatePort ;
93
92
publicPort = containerListResponse.Ports.Single(port => port.PrivatePort == privatePort).PublicPort;
94
93
95
94
containerId = containerListResponse.ID;
96
95
}
97
- // }
96
+ }*/
98
97
99
98
var httpMessageHandler = new HttpClientHandler ( )
100
99
{
@@ -105,7 +104,7 @@ public async Task InitializeAsync()
105
104
_database = new CosmosDatabase ( new CosmosOptions
106
105
{
107
106
ConnectionString =
108
- $ "AccountEndpoint=https://localhost:{ publicPort } / ;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
107
+ $ "AccountEndpoint=https://localhost:8081 ;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
109
108
DatabaseName = "database" ,
110
109
CollectionName = $ "testContainer",
111
110
AllowTableCreation = true ,
0 commit comments