In the past we always had often problems to manage logging mechanisms in unit tests, so I wrote ThrowAwayLogger that solves the problem.
// field
private ILogger _log = new ThrowAwayLogger();
// call
_log.Log(LogLevel.Information, _ex, "Test " + _message);
}
In principle, all this can be implemented via Moq, but there are often cases where validations are not necessary and a simple mock mechanism is sufficient.
ThrowAwayLogger on GitHub
Autor
Benjamin Abt
Ben is a passionate developer and software architect and especially focused on .NET, cloud and IoT. In his professional he works on high-scalable platforms for IoT and Industry 4.0 focused on the next generation of connected industry based on Azure and .NET. He runs the largest german-speaking C# forum myCSharp.de, is the founder of the Azure UserGroup Stuttgart, a co-organizer of the AzureSaturday, runs his blog, participates in open source projects, speaks at various conferences and user groups and also has a bit free time. He is a Microsoft MVP since 2015 for .NET and Azure.