-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogTests.cs
39 lines (33 loc) · 1.05 KB
/
LogTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using Serilog;
using Serilog.Events;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
namespace SceneSkope.Serilog.Sinks.XUnit.Tests
{
public class LogTests
{
private ILogger Log { get; }
private readonly TestOutputHelper _output;
public LogTests(ITestOutputHelper output)
{
_output = output as TestOutputHelper;
Log = output.CreateSerilogLogger(LogEventLevel.Verbose);
}
[Fact]
public void TestLogGoesToOutput()
{
Assert.Empty(_output.Output);
Log.Information("Simple test");
Assert.Equal($"[Information] Simple test{Environment.NewLine}", _output.Output);
}
[Fact]
public void TestLogWithExceptionGoesToOutput()
{
Assert.Empty(_output.Output);
Log.Error(new Exception("Error"), "Got error");
Assert.Equal($"[Error] Got error{Environment.NewLine}System.Exception: Error{Environment.NewLine}{Environment.NewLine}", _output.Output);
}
}
}