File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Serilog.Settings.Configuration.Tests Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,37 @@ public void PropertyEnrichmentIsApplied()
40
40
Assert . Equal ( "Test" , evt . Properties [ "App" ] . LiteralValue ( ) ) ;
41
41
}
42
42
43
+ [ Theory ]
44
+ [ InlineData ( "extended syntax" ,
45
+ @"{
46
+ ""Serilog"": {
47
+ ""Using"": [""TestDummies""],
48
+ ""WriteTo"": [
49
+ { ""Name"": ""DummyConsole""},
50
+ { ""Name"": ""DummyWithLevelSwitch""},
51
+ ]
52
+ }
53
+ }" ) ]
54
+ [ InlineData ( "simplified syntax" ,
55
+ @"{
56
+ ""Serilog"": {
57
+ ""Using"": [""TestDummies""],
58
+ ""WriteTo"": [""DummyConsole"", ""DummyWithLevelSwitch"" ]
59
+ }
60
+ }" ) ]
61
+ public void ParameterlessSinksAreConfigured ( string syntax , string json )
62
+ {
63
+ var log = ConfigFromJson ( json )
64
+ . CreateLogger ( ) ;
65
+
66
+ DummyConsoleSink . Emitted . Clear ( ) ;
67
+ DummyWithLevelSwitchSink . Emitted . Clear ( ) ;
68
+
69
+ log . Write ( Some . InformationEvent ( ) ) ;
70
+
71
+ Assert . Equal ( 1 , DummyConsoleSink . Emitted . Count ) ;
72
+ Assert . Equal ( 1 , DummyWithLevelSwitchSink . Emitted . Count ) ;
73
+ }
43
74
44
75
[ Fact ]
45
76
public void SinksAreConfigured ( )
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using Serilog . Core ;
3
4
using Serilog . Events ;
4
5
using TestDummies . Console . Themes ;
@@ -15,8 +16,14 @@ public DummyConsoleSink(ConsoleTheme theme = null)
15
16
[ ThreadStatic ]
16
17
public static ConsoleTheme Theme ;
17
18
19
+ [ ThreadStatic ]
20
+ // ReSharper disable ThreadStaticFieldHasInitializer
21
+ public static List < LogEvent > Emitted = new List < LogEvent > ( ) ;
22
+ // ReSharper restore ThreadStaticFieldHasInitializer
23
+
18
24
public void Emit ( LogEvent logEvent )
19
25
{
26
+ Emitted . Add ( logEvent ) ;
20
27
}
21
28
}
22
29
You can’t perform that action at this time.
0 commit comments