@@ -346,39 +346,32 @@ public void TestComputedWaitQueueSize_UsingSize()
346
346
}
347
347
348
348
[ Theory ]
349
- [ InlineData ( null , null , "mongodb://localhost" , null ) ]
350
- [ InlineData ( new [ ] { CompressorType . Zlib } , null , "mongodb://localhost/?compressors={0}" , new [ ] { CompressorType . Zlib } ) ]
351
- [ InlineData ( new [ ] { CompressorType . Zlib } , "Level&zlibCompressionLevel&1" , "mongodb://localhost/?compressors={0}" , new [ ] { CompressorType . Zlib } ) ]
352
- [ InlineData ( new [ ] { CompressorType . Snappy } , null , "mongodb://localhost/?compressors={0}" , new [ ] { CompressorType . Snappy } ) ]
353
- [ InlineData ( new [ ] { CompressorType . Snappy , CompressorType . Zlib } , null , "mongodb://localhost/?compressors={0}" , new [ ] { CompressorType . Snappy , CompressorType . Zlib } ) ]
354
- public void TestCompressors ( CompressorType [ ] compressors , string compressionProperty , string formatString , CompressorType [ ] values )
349
+ [ InlineData ( null , "mongodb://localhost" ) ]
350
+ [ InlineData ( new [ ] { CompressorType . Zlib } , "mongodb://localhost/?compressors=zlib" ) ]
351
+ [ InlineData ( new [ ] { CompressorType . ZStandard } , "mongodb://localhost/?compressors=zstd" ) ]
352
+ [ InlineData ( new [ ] { CompressorType . Snappy } , "mongodb://localhost/?compressors=snappy" ) ]
353
+ [ InlineData ( new [ ] { CompressorType . Snappy , CompressorType . Zlib } , "mongodb://localhost/?compressors=snappy,zlib" ) ]
354
+ [ InlineData ( new [ ] { CompressorType . ZStandard , CompressorType . Snappy , CompressorType . Zlib } , "mongodb://localhost/?compressors=zstd,snappy,zlib" ) ]
355
+ public void TestCompressors ( CompressorType [ ] compressors , string expectedConnectionString )
355
356
{
356
357
var subject = new MongoUrlBuilder { Server = _localhost } ;
357
- if ( compressors != null )
358
- {
359
- subject . Compressors = compressors
360
- . Select ( x =>
361
- {
362
- var compression = new CompressorConfiguration ( x ) ;
363
- if ( ! string . IsNullOrWhiteSpace ( compressionProperty ) )
364
- {
365
- var @params = compressionProperty . Split ( '&' ) ;
366
- compression . Properties . Add ( @params [ 0 ] , @params [ 2 ] ) ;
367
- }
368
- return compression ;
369
- } )
370
- . ToList ( ) ;
371
- }
372
358
373
- Assert . Equal ( compressors ?? new CompressorType [ 0 ] , subject . Compressors . Select ( x => x . Type ) ) ;
374
- var expectedValues = values == null ? string . Empty : string . Join ( "," , values . Select ( c => c . ToString ( ) . ToLower ( ) ) ) ;
375
- if ( ! string . IsNullOrWhiteSpace ( compressionProperty ) )
376
- {
377
- var @params = compressionProperty . Split ( '&' ) ;
378
- expectedValues += $ "&{ @params [ 1 ] } ={ @params [ 2 ] } ";
379
- }
380
- var canonicalConnectionString = string . Format ( formatString , expectedValues ) ;
381
- Assert . Equal ( canonicalConnectionString , subject . ToString ( ) ) ;
359
+ subject . Compressors = compressors ? . Select ( x => new CompressorConfiguration ( x ) ) . ToList ( ) ;
360
+ var connectionString = subject . ToString ( ) ;
361
+
362
+ Assert . Equal ( expectedConnectionString , connectionString ) ;
363
+ }
364
+
365
+ [ Fact ]
366
+ public void TestCompressorProperties ( )
367
+ {
368
+ var subject = new MongoUrlBuilder { Server = _localhost } ;
369
+
370
+ var zlibCompressor = new CompressorConfiguration ( CompressorType . Zlib ) { Properties = { { "Level" , 1 } } } ;
371
+ subject . Compressors = new [ ] { zlibCompressor } ;
372
+ var connectionString = subject . ToString ( ) ;
373
+
374
+ Assert . Equal ( "mongodb://localhost/?compressors=zlib&zlibCompressionLevel=1" , connectionString ) ;
382
375
}
383
376
384
377
[ Theory ]
0 commit comments