Created
June 17, 2016 22:25
-
-
Save JoshuaCode/38281270bb9cd52bb44143662afa0dbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonControllerTests | |
{ | |
public PersonControllerTests(ITestOutputHelper output) | |
{ | |
var correlationId = Guid.NewGuid().ToString(); | |
var logger = new LoggerConfiguration() | |
.MinimumLevel.Debug() | |
.Enrich.FromLogContext() | |
.WriteTo.XunitTestOutput(output, | |
outputTemplate: "{Timestamp:u} [{Level}] ({CorrelationId}) {Message}{NewLine}{Exception}") | |
.CreateLogger().ForContext("CorrelationId", correlationId); | |
_loggerFactory = new LoggerFactory(); | |
_loggerFactory.AddSerilog(logger); | |
} | |
private readonly ILoggerFactory _loggerFactory; | |
[Fact] | |
public void Get_persons() | |
{ | |
//Act | |
var controller = new PersonController(_loggerFactory); | |
var result = controller.Get(); | |
//Assert | |
Assert.Contains("value1", result); | |
Assert.Contains("value2", result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment