From 067f7a68dcddf5647b5bca5d53b7b8d383b97ec1 Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh Date: Mon, 6 Jan 2025 14:37:45 +0100 Subject: [PATCH] Add missing tests --- src/Core.UnitTests/Logging/LoggerBaseTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) 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"); + } }