Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TestBase allowing for internal logging etc
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace InfinityCrawler.Tests | ||
{ | ||
[TestClass] | ||
public class TestBase | ||
{ | ||
private ILoggerFactory LoggerFactory { get; } | ||
|
||
public TestBase() | ||
{ | ||
var serviceProvider = new ServiceCollection() | ||
.AddLogging(builder => | ||
{ | ||
builder.AddFilter("InfinityCrawler", LogLevel.Trace); | ||
builder.AddConsole(); | ||
builder.AddDebug(); | ||
}) | ||
.BuildServiceProvider(); | ||
|
||
LoggerFactory = serviceProvider.GetService<ILoggerFactory>(); | ||
} | ||
|
||
protected ILogger<T> GetLogger<T>() | ||
{ | ||
return LoggerFactory.CreateLogger<T>(); | ||
} | ||
} | ||
} |