Skip to content

Commit 2d38c4e

Browse files
committed
- Add new test for IEnumerable<string> scope type
1 parent 23db1d5 commit 2d38c4e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Logging.XUnit.Tests/XUnitLoggerTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,44 @@ public static void XUnitLogger_Log_Logs_Message_If_Scopes_Included_And_There_Are
615615
mock.Verify((p) => p.WriteLine(expected), Times.Once());
616616
}
617617

618+
[Fact]
619+
public static void XUnitLogger_Log_Logs_Message_If_Scopes_Included_And_There_Is_Scope_Of_IEnumerable()
620+
{
621+
// Arrange
622+
var mock = new Mock<ITestOutputHelper>();
623+
624+
string name = "MyName";
625+
var outputHelper = mock.Object;
626+
627+
var options = new XUnitLoggerOptions()
628+
{
629+
Filter = FilterTrue,
630+
IncludeScopes = true,
631+
};
632+
633+
var logger = new XUnitLogger(name, outputHelper, options)
634+
{
635+
Clock = StaticClock,
636+
};
637+
638+
string expected = string.Join(
639+
Environment.NewLine,
640+
"[2018-08-19 16:12:16Z] info: MyName[0]",
641+
" => ScopeKeyOne",
642+
" => ScopeKeyTwo",
643+
" => ScopeKeyThree",
644+
" Message|False|False");
645+
646+
// Act
647+
using (logger.BeginScope(new[] { "ScopeKeyOne", "ScopeKeyTwo", "ScopeKeyThree" }))
648+
{
649+
logger.Log<string>(LogLevel.Information, 0, null, null, Formatter);
650+
}
651+
652+
// Assert
653+
mock.Verify((p) => p.WriteLine(expected), Times.Once());
654+
}
655+
618656
private static DateTimeOffset StaticClock() => new DateTimeOffset(2018, 08, 19, 17, 12, 16, TimeSpan.FromHours(1));
619657

620658
private static bool FilterTrue(string categoryName, LogLevel level) => true;

0 commit comments

Comments
 (0)