public void PureSeriLogger_LogContext_CreateLogScope_Null() { var pureSeriLogContext = new PureSeriLogContext(); Func <IDisposable> fx = () => pureSeriLogContext.CreateLogScope(null); fx.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("properties"); }
public void PureSeriLogger_LogContext_CreateLogScope() { var pureSeriLogContext = new PureSeriLogContext(); const string testProperty = "Property"; const string testValue = "Value"; const string testLogMsg = "Test Message"; var logPropertyList = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(testProperty, testValue) }; using (TestCorrelator.CreateContext()) using (pureSeriLogContext.CreateLogScope(logPropertyList)) { _pureSeriLogger.LogDebug(testLogMsg); var currentTestContext = TestCorrelator.GetLogEventsFromCurrentContext().ToList(); currentTestContext.Should().ContainSingle().Which.Properties.ContainsKey(testProperty).Should().BeTrue(); currentTestContext.Should().ContainSingle().Which.Properties[testProperty].ToString().Should().Be(testValue.ToDoubleQuoted()); currentTestContext.Should().ContainSingle().Which.MessageTemplate.Text.Should().Be(testLogMsg); } }