diff --git a/src/Core.UnitTests/Logging/LoggerBaseTests.cs b/src/Core.UnitTests/Logging/LoggerBaseTests.cs index b34c79f0a..f75e36a54 100644 --- a/src/Core.UnitTests/Logging/LoggerBaseTests.cs +++ b/src/Core.UnitTests/Logging/LoggerBaseTests.cs @@ -161,6 +161,26 @@ public void LogVerbose_AllContextsEnabled_AddsInCorrectOrder() writer.Received().WriteLine($"[DEBUG] [ThreadId {Thread.CurrentThread.ManagedThreadId}] [context] [verbose context] msg sent"); } + [TestMethod] + public void LogVerboseWithContext_AllContextsEnabled_AddsInCorrectOrder() + { + var messageLevelContext = new MessageLevelContext + { + Context = Substitute.For>(), + VerboseContext = Substitute.For>() + }; + settingsProvider.IsThreadIdEnabled.Returns(true); + settingsProvider.IsVerboseEnabled.Returns(true); + contextManager.GetFormattedContextOrNull(default).Returns("context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); + contextManager.GetFormattedContextOrNull(messageLevelContext).Returns("context with message level"); + contextManager.GetFormattedVerboseContextOrNull(messageLevelContext).Returns("verbose context with message level"); + + testSubject.LogVerbose(messageLevelContext, "msg {0}", "sent"); + + writer.Received().WriteLine($"[DEBUG] [ThreadId {Thread.CurrentThread.ManagedThreadId}] [context with message level] [verbose context with message level] msg sent"); + } + [TestMethod] public void WriteLine_VerboseDisabled_Writes() { @@ -316,4 +336,24 @@ public void WriteLineFormatted_AllContextsEnabled_AddsInCorrectOrder() writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] [context] [verbose context] msg sent"); } + + [TestMethod] + public void WriteLineFormattedWithContext_AllContextsEnabled_AddsInCorrectOrder() + { + var messageLevelContext = new MessageLevelContext + { + Context = Substitute.For>(), + VerboseContext = Substitute.For>() + }; + settingsProvider.IsThreadIdEnabled.Returns(true); + settingsProvider.IsVerboseEnabled.Returns(true); + contextManager.GetFormattedContextOrNull(default).Returns("context"); + contextManager.GetFormattedVerboseContextOrNull(default).Returns("verbose context"); + contextManager.GetFormattedContextOrNull(messageLevelContext).Returns("context with message level"); + contextManager.GetFormattedVerboseContextOrNull(messageLevelContext).Returns("verbose context with message level"); + + testSubject.WriteLine(messageLevelContext, "msg {0}", "sent"); + + writer.Received().WriteLine($"[ThreadId {Thread.CurrentThread.ManagedThreadId}] [context with message level] [verbose context with message level] msg sent"); + } }