15
15
namespace ManagedCode . Database . Tests . TestContainers ;
16
16
17
17
[ CollectionDefinition ( nameof ( CosmosTestContainer ) ) ]
18
- public class CosmosTestContainer : ITestContainer < string , TestCosmosItem > ,
18
+ public class CosmosTestContainer : ITestContainer < string , TestCosmosItem > ,
19
19
ICollectionFixture < CosmosTestContainer > , IDisposable
20
20
{
21
21
private readonly TestcontainersContainer _cosmosTestContainer ;
@@ -83,21 +83,22 @@ public async Task InitializeAsync()
83
83
var listContainers = await _dockerClient . Containers . ListContainersAsync ( new ContainersListParameters ( ) ) ;
84
84
85
85
ContainerListResponse containerListResponse = listContainers . FirstOrDefault ( container => container . Names . Contains ( $ "/{ containerName } ") ) ;
86
-
87
- if ( containerListResponse != null )
86
+
87
+ if ( containerListResponse != null )
88
88
{
89
89
publicPort = containerListResponse . Ports . Single ( port => port . PrivatePort == privatePort ) . PublicPort ;
90
90
91
91
containerId = containerListResponse . ID ;
92
92
}
93
93
}
94
94
95
+
95
96
_database = new CosmosDatabase ( new CosmosOptions
96
97
{
97
98
ConnectionString =
98
99
$ "AccountEndpoint=https://localhost:{ publicPort } /;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
99
100
DatabaseName = "database" ,
100
- CollectionName = $ "testContainers ",
101
+ CollectionName = $ "testContainer ",
101
102
AllowTableCreation = true ,
102
103
CosmosClientOptions = new CosmosClientOptions ( )
103
104
{
@@ -120,7 +121,7 @@ public async Task InitializeAsync()
120
121
121
122
public async Task DisposeAsync ( )
122
123
{
123
- await _database . DeleteAsync ( ) ;
124
+ // await _database.DeleteAsync();
124
125
await _database . DisposeAsync ( ) ;
125
126
126
127
/* _testOutputHelper.WriteLine($"Cosmos container State:{_cosmosContainer.State}");
0 commit comments