@@ -426,28 +426,66 @@ public void SinkWithIConfigurationArguments()
426
426
""Using"": [""TestDummies""],
427
427
""WriteTo"": [{
428
428
""Name"": ""DummyWithConfiguration"",
429
- ""Args"": {""pathFormat"" : ""C:\\"",
430
- ""configurationSection"" : { ""foo"" : ""bar"" } }
429
+ ""Args"": {}
431
430
}]
432
431
}
433
432
}" ;
434
433
435
- // IConfiguration and IConfigurationSection arguments do not have
436
- // default values so they will throw if they are not populated
434
+ DummyConfigurationSink . Reset ( ) ;
435
+ var log = ConfigFromJson ( json )
436
+ . CreateLogger ( ) ;
437
437
438
+ log . Write ( Some . InformationEvent ( ) ) ;
439
+
440
+ Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
441
+ }
442
+
443
+ [ Fact ]
444
+ public void SinkWithOptionalIConfigurationArguments ( )
445
+ {
446
+ var json = @"{
447
+ ""Serilog"": {
448
+ ""Using"": [""TestDummies""],
449
+ ""WriteTo"": [{
450
+ ""Name"": ""DummyWithOptionalConfiguration"",
451
+ ""Args"": {}
452
+ }]
453
+ }
454
+ }" ;
438
455
439
456
DummyConfigurationSink . Reset ( ) ;
440
457
var log = ConfigFromJson ( json )
441
458
. CreateLogger ( ) ;
442
459
443
-
444
460
log . Write ( Some . InformationEvent ( ) ) ;
445
461
446
462
Assert . NotNull ( DummyConfigurationSink . Configuration ) ;
463
+ }
464
+
465
+ [ Fact ]
466
+ public void SinkWithIConfigSectionArguments ( )
467
+ {
468
+ var json = @"{
469
+ ""Serilog"": {
470
+ ""Using"": [""TestDummies""],
471
+ ""WriteTo"": [{
472
+ ""Name"": ""DummyWithConfigSection"",
473
+ ""Args"": {""configurationSection"" : { ""foo"" : ""bar"" } }
474
+ }]
475
+ }
476
+ }" ;
477
+
478
+ DummyConfigurationSink . Reset ( ) ;
479
+ var log = ConfigFromJson ( json )
480
+ . CreateLogger ( ) ;
481
+
482
+ log . Write ( Some . InformationEvent ( ) ) ;
483
+
447
484
Assert . NotNull ( DummyConfigurationSink . ConfigSection ) ;
448
485
Assert . Equal ( "bar" , DummyConfigurationSink . ConfigSection [ "foo" ] ) ;
449
486
}
450
487
488
+
451
489
[ Fact ]
452
490
public void SinkWithConfigurationBindingArgument ( )
453
491
{
0 commit comments