Skip to content

Commit

Permalink
Added tests from serilog#91 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
merbla committed Apr 5, 2018
1 parent e0ac44f commit a201884
Showing 1 changed file with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,73 @@ public void LoggingLevelSwitchCanBeUsedForMinimumLevelOverrides()
Assert.False(evt is null, "LoggingLevelSwitch level was changed to Information for logger System.*. It should now log Information events for SourceContext System.Bar.");
// ReSharper restore HeuristicUnreachableCode
}


[Trait("Bugfix", "#91")]
[Fact]
public void WriteToLoggerWithRestrictedToMinimumLevelIsSupported()
{
var json = @"{
""Serilog"": {
""Using"": [""TestDummies""],
""WriteTo"": [{
""Name"": ""Logger"",
""Args"": {
""configureLogger"" : {
""WriteTo"": [{
""Name"": ""DummyRollingFile"",
""Args"": {""pathFormat"" : ""C:\\""}
}]},
""restrictedToMinimumLevel"": ""Warning""
}
}]
}
}";

var log = ConfigFromJson(json)
.CreateLogger();

DummyRollingFileSink.Emitted.Clear();

log.Write(Some.InformationEvent());
log.Write(Some.WarningEvent());

Assert.Equal(1, DummyRollingFileSink.Emitted.Count);
}

[Trait("Bugfix", "#91")]
[Fact]
public void WriteToSubLoggerWithLevelSwitchIsSupported()
{
var json = @"{
""Serilog"": {
""Using"": [""TestDummies""],
""LevelSwitches"": {""$switch1"" : ""Warning"" },
""MinimumLevel"" : {
""ControlledBy"" : ""$switch1""
},
""WriteTo"": [{
""Name"": ""Logger"",
""Args"": {
""configureLogger"" : {
""WriteTo"": [{
""Name"": ""DummyRollingFile"",
""Args"": {""pathFormat"" : ""C:\\""}
}]}
}
}]
}
}";

var log = ConfigFromJson(json)
.CreateLogger();

DummyRollingFileSink.Emitted.Clear();

log.Write(Some.InformationEvent());
log.Write(Some.WarningEvent());

Assert.Equal(1, DummyRollingFileSink.Emitted.Count);
}
}
}

0 comments on commit a201884

Please sign in to comment.