Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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