generated from dailydevops/dotnet-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
127 additions
and
128 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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
1 change: 0 additions & 1 deletion
1
tests/NetEvolve.Logging.XUnit.Tests.Integration/GlobalUsings.cs
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
tests/NetEvolve.Logging.XUnit.Tests.Unit/XUnitLoggerProviderTests.cs
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,88 @@ | ||
namespace NetEvolve.Logging.XUnit.Tests.Unit; | ||
|
||
using System; | ||
using Microsoft.Extensions.Logging; | ||
using NetEvolve.Logging.Abstractions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class XUnitLoggerProviderTests | ||
{ | ||
private readonly ITestOutputHelper _testOutputHelper; | ||
|
||
public XUnitLoggerProviderTests(ITestOutputHelper testOutputHelper) => | ||
_testOutputHelper = testOutputHelper; | ||
|
||
[Fact] | ||
public void CreateLogger_WithTestOutputHelper() | ||
{ | ||
// Arrange | ||
using var provider = new XUnitLoggerProvider(_testOutputHelper); | ||
|
||
// Act | ||
var logger = provider.CreateLogger(nameof(XUnitLoggerProviderTests)); | ||
|
||
// Assert | ||
Assert.NotNull(logger); | ||
_ = Assert.IsType<XUnitLogger>(logger); | ||
} | ||
|
||
[Fact] | ||
public void CreateLoggerGeneric_WithTestOutputHelper() | ||
{ | ||
// Arrange | ||
using var provider = new XUnitLoggerProvider(_testOutputHelper); | ||
|
||
// Act | ||
var logger = provider.CreateLogger<XUnitLoggerProviderTests>(); | ||
|
||
// Assert | ||
Assert.NotNull(logger); | ||
_ = Assert.IsType<XUnitLogger<XUnitLoggerProviderTests>>(logger); | ||
} | ||
|
||
[Fact] | ||
public void SetScopeProvider_Null_ThrowArgumentNullException() | ||
{ | ||
// Arrange | ||
using var provider = new XUnitLoggerProvider(_testOutputHelper); | ||
|
||
// Act | ||
void Act() => provider.SetScopeProvider(null!); | ||
|
||
// Assert | ||
_ = Assert.Throws<ArgumentNullException>("scopeProvider", Act); | ||
} | ||
|
||
[Fact] | ||
public void SetScopeProvider_WithNullScopeProvider_NoExceptionThrown() | ||
{ | ||
// Arrange | ||
using var provider = new XUnitLoggerProvider(_testOutputHelper); | ||
|
||
// Act | ||
var ex = Record.Exception( | ||
() => provider.SetScopeProvider(NullExternalScopeProvider.Instance) | ||
); | ||
|
||
// Assert | ||
Assert.Null(ex); | ||
} | ||
|
||
[Fact] | ||
public void SetScopeProvider_WithScopeProvider_Expected() | ||
{ | ||
// Arrange | ||
using var provider = new XUnitLoggerProvider(_testOutputHelper); | ||
var scopeProvider = new LoggerExternalScopeProvider(); | ||
|
||
// Act | ||
provider.SetScopeProvider(scopeProvider); | ||
|
||
// Assert | ||
foreach (var logger in provider.Loggers) | ||
{ | ||
Assert.Same(scopeProvider, logger.ScopeProvider); | ||
} | ||
} | ||
} |