@@ -62,10 +62,9 @@ public void Explicit_encryption_with_libmongocrypt_package_works()
62
62
keyVaultNamespace ,
63
63
kmsProviders ) ;
64
64
65
- var clientEncryption = new ClientEncryption ( clientEncryptionSettings ) ;
65
+ using var clientEncryption = new ClientEncryption ( clientEncryptionSettings ) ;
66
66
var dataKeyId = clientEncryption . CreateDataKey ( "local" , new DataKeyOptions ( ) , CancellationToken . None ) ;
67
67
var base64DataKeyId = Convert . ToBase64String ( GuidConverter . ToBytes ( dataKeyId , GuidRepresentation . Standard ) ) ;
68
- clientEncryption . Dispose ( ) ;
69
68
70
69
var collectionNamespace = CollectionNamespace . FromFullName ( "test.coll" ) ;
71
70
@@ -100,14 +99,22 @@ public void Explicit_encryption_with_libmongocrypt_package_works()
100
99
clientSettings . LoggingSettings = new LoggingSettings ( loggerFactory ) ;
101
100
102
101
var client = new MongoClient ( clientSettings ) ;
103
- var database = client . GetDatabase ( "test" ) ;
104
- database . DropCollection ( "coll" ) ;
105
- var collection = database . GetCollection < BsonDocument > ( "coll" ) ;
106
102
107
- collection . InsertOne ( new BsonDocument ( "encryptedField" , "123456789" ) ) ;
103
+ try
104
+ {
105
+ var database = client . GetDatabase ( "test" ) ;
106
+ database . DropCollection ( "coll" ) ;
107
+ var collection = database . GetCollection < BsonDocument > ( "coll" ) ;
108
+
109
+ collection . InsertOne ( new BsonDocument ( "encryptedField" , "123456789" ) ) ;
108
110
109
- var result = collection . Find ( FilterDefinition < BsonDocument > . Empty ) . First ( ) ;
110
- _output . WriteLine ( result . ToJson ( ) ) ;
111
+ var result = collection . Find ( FilterDefinition < BsonDocument > . Empty ) . First ( ) ;
112
+ _output . WriteLine ( result . ToJson ( ) ) ;
113
+ }
114
+ finally
115
+ {
116
+ ClusterRegistry . Instance . UnregisterAndDisposeCluster ( client . Cluster ) ;
117
+ }
111
118
}
112
119
113
120
var expectedLogs = new [ ]
0 commit comments