@@ -13,13 +13,23 @@ namespace Serilog.Settings.Configuration.Tests
1313 public class ConfigurationSettingsTests
1414 {
1515 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 )
1626 {
1727 var builder = new ConfigurationBuilder ( ) . AddJsonString ( jsonString ) ;
1828 if ( secondJsonSource != null )
1929 builder . AddJsonString ( secondJsonSource ) ;
20- var config = builder . Build ( ) ;
30+ configuration = builder . Build ( ) ;
2131 return new LoggerConfiguration ( )
22- . ReadFrom . Configuration ( config ) ;
32+ . ReadFrom . Configuration ( configuration ) ;
2333 }
2434
2535 [ Fact ]
@@ -419,7 +429,7 @@ public void LoggingLevelSwitchCanBeUsedForMinimumLevelOverrides()
419429 }
420430
421431 [ Fact ]
422-
432+
423433 [ Trait ( "BugFix" , "https://github.com/serilog/serilog-settings-configuration/issues/142" ) ]
424434 public void SinkWithIConfigurationArguments ( )
425435 {
@@ -434,14 +444,15 @@ public void SinkWithIConfigurationArguments()
434444 }" ;
435445
436446 DummyConfigurationSink . Reset ( ) ;
437- var log = ConfigFromJson ( json )
447+ var log = ConfigFromJson ( json , out var expectedConfig )
438448 . CreateLogger ( ) ;
439449
440450 log . Write ( Some . InformationEvent ( ) ) ;
441451
442452 Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
453+ Assert . Same ( expectedConfig , DummyConfigurationSink . Configuration ) ;
443454 }
444-
455+
445456 [ Fact ]
446457 [ Trait ( "BugFix" , "https://github.com/serilog/serilog-settings-configuration/issues/142" ) ]
447458 public void SinkWithOptionalIConfigurationArguments ( )
@@ -457,15 +468,16 @@ public void SinkWithOptionalIConfigurationArguments()
457468 }" ;
458469
459470 DummyConfigurationSink . Reset ( ) ;
460- var log = ConfigFromJson ( json )
471+ var log = ConfigFromJson ( json , out var expectedConfig )
461472 . CreateLogger ( ) ;
462473
463474 log . Write ( Some . InformationEvent ( ) ) ;
464475
465476 // null is the default value, but we have a configuration to provide
466477 Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
478+ Assert . Same ( expectedConfig , DummyConfigurationSink . Configuration ) ;
467479 }
468-
480+
469481 [ Fact ]
470482 public void SinkWithIConfigSectionArguments ( )
471483 {
@@ -484,7 +496,7 @@ public void SinkWithIConfigSectionArguments()
484496 . CreateLogger ( ) ;
485497
486498 log . Write ( Some . InformationEvent ( ) ) ;
487-
499+
488500 Assert . NotNull ( DummyConfigurationSink . ConfigSection ) ;
489501 Assert . Equal ( "bar" , DummyConfigurationSink . ConfigSection [ "foo" ] ) ;
490502 }
@@ -763,7 +775,7 @@ public void DestructureLimitsCollectionCount()
763775 Assert . DoesNotContain ( "4" , msg ) ;
764776 }
765777
766- private string GetDestructuredProperty ( object x , string json )
778+ private static string GetDestructuredProperty ( object x , string json )
767779 {
768780 LogEvent evt = null ;
769781 var log = ConfigFromJson ( json )
0 commit comments