@@ -13,13 +13,23 @@ namespace Serilog.Settings.Configuration.Tests
13
13
public class ConfigurationSettingsTests
14
14
{
15
15
static LoggerConfiguration ConfigFromJson ( string jsonString , string secondJsonSource = null )
16
+ {
17
+ return ConfigFromJson ( jsonString , secondJsonSource , out _ ) ;
18
+ }
19
+
20
+ static LoggerConfiguration ConfigFromJson ( string jsonString , out IConfiguration configuration )
21
+ {
22
+ return ConfigFromJson ( jsonString , null , out configuration ) ;
23
+ }
24
+
25
+ static LoggerConfiguration ConfigFromJson ( string jsonString , string secondJsonSource , out IConfiguration configuration )
16
26
{
17
27
var builder = new ConfigurationBuilder ( ) . AddJsonString ( jsonString ) ;
18
28
if ( secondJsonSource != null )
19
29
builder . AddJsonString ( secondJsonSource ) ;
20
- var config = builder . Build ( ) ;
30
+ configuration = builder . Build ( ) ;
21
31
return new LoggerConfiguration ( )
22
- . ReadFrom . Configuration ( config ) ;
32
+ . ReadFrom . Configuration ( configuration ) ;
23
33
}
24
34
25
35
[ Fact ]
@@ -419,7 +429,7 @@ public void LoggingLevelSwitchCanBeUsedForMinimumLevelOverrides()
419
429
}
420
430
421
431
[ Fact ]
422
-
432
+
423
433
[ Trait ( "BugFix" , "https://github.com/serilog/serilog-settings-configuration/issues/142" ) ]
424
434
public void SinkWithIConfigurationArguments ( )
425
435
{
@@ -434,14 +444,15 @@ public void SinkWithIConfigurationArguments()
434
444
}" ;
435
445
436
446
DummyConfigurationSink . Reset ( ) ;
437
- var log = ConfigFromJson ( json )
447
+ var log = ConfigFromJson ( json , out var expectedConfig )
438
448
. CreateLogger ( ) ;
439
449
440
450
log . Write ( Some . InformationEvent ( ) ) ;
441
451
442
452
Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
453
+ Assert . Same ( expectedConfig , DummyConfigurationSink . Configuration ) ;
443
454
}
444
-
455
+
445
456
[ Fact ]
446
457
[ Trait ( "BugFix" , "https://github.com/serilog/serilog-settings-configuration/issues/142" ) ]
447
458
public void SinkWithOptionalIConfigurationArguments ( )
@@ -457,15 +468,16 @@ public void SinkWithOptionalIConfigurationArguments()
457
468
}" ;
458
469
459
470
DummyConfigurationSink . Reset ( ) ;
460
- var log = ConfigFromJson ( json )
471
+ var log = ConfigFromJson ( json , out var expectedConfig )
461
472
. CreateLogger ( ) ;
462
473
463
474
log . Write ( Some . InformationEvent ( ) ) ;
464
475
465
476
// null is the default value, but we have a configuration to provide
466
477
Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
478
+ Assert . Same ( expectedConfig , DummyConfigurationSink . Configuration ) ;
467
479
}
468
-
480
+
469
481
[ Fact ]
470
482
public void SinkWithIConfigSectionArguments ( )
471
483
{
@@ -484,7 +496,7 @@ public void SinkWithIConfigSectionArguments()
484
496
. CreateLogger ( ) ;
485
497
486
498
log . Write ( Some . InformationEvent ( ) ) ;
487
-
499
+
488
500
Assert . NotNull ( DummyConfigurationSink . ConfigSection ) ;
489
501
Assert . Equal ( "bar" , DummyConfigurationSink . ConfigSection [ "foo" ] ) ;
490
502
}
@@ -763,7 +775,7 @@ public void DestructureLimitsCollectionCount()
763
775
Assert . DoesNotContain ( "4" , msg ) ;
764
776
}
765
777
766
- private string GetDestructuredProperty ( object x , string json )
778
+ private static string GetDestructuredProperty ( object x , string json )
767
779
{
768
780
LogEvent evt = null ;
769
781
var log = ConfigFromJson ( json )
0 commit comments