serilog-contrib / SerilogSinksInMemory

In-memory sink for Serilog to use for testing
MIT License
53 stars 7 forks source link

Target net45 and switch to NUnit #8

Closed sandermvanvliet closed 4 years ago

sandermvanvliet commented 4 years ago

This PR changes the minimum supported framework to net45. In order to make that possible the test framework was switched from xUnit to NUnit as the former has a lower bound of net462 so that prevented the tests from running.

net45 does not support AsyncLocal<T> so the sink has been switched to use ThreadLocal<T>.

When using the sink for testing it is important that you add a tear-down step to call Dispose() on the logger to clear the LogEvents collection of the sink. This will prevent flaky tests due to the fact that test isolation in NUnit is per assembly and not test. (Though this is a problem for net45 / net462 mostly but your mileage may vary)