Last active
April 13, 2020 15:03
-
-
Save changhuixu/c5d919e24a4c44b21f816c0662c6b7ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[TestMethod] | |
public void TestWithConsoleLogger() | |
{ | |
using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | |
var logger = loggerFactory.CreateLogger<CalculationService>(); | |
var svc = new CalculationService(logger); | |
var result = svc.AddTwoPositiveNumbers(1, 2); | |
Assert.AreEqual(3, result); | |
// If you are using .NET Core 2.1. | |
//using (var loggerFactory = new LoggerFactory().AddConsole()) // Need to use "using" in order to flush Console output | |
//{ | |
// var logger = loggerFactory.CreateLogger<CalculationService>(); | |
// var svc = new CalculationService(logger); | |
// var result = svc.AddTwoPositiveNumbers(1, 2); | |
// Assert.AreEqual(3, result); | |
//} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment