Skip to content

Commit

Permalink
Send integration test logs to xUnit output
Browse files Browse the repository at this point in the history
  • Loading branch information
martincostello authored Jul 4, 2020
1 parent 86a1680 commit a92f48d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,7 @@ $RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

# Arcade-related folders
.dotnet/
artifacts/
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PackageVersion Include="AngleSharp" Version="0.14.0" />
<PackageVersion Include="EntityFramework" Version="6.4.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.1.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenIddict.Abstractions;
using OpenIddict.Server.FunctionalTests;
using Xunit;
using Xunit.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using static OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers;
using static OpenIddict.Server.OpenIddictServerEvents;
Expand All @@ -29,6 +31,11 @@ namespace OpenIddict.Server.AspNetCore.FunctionalTests
{
public partial class OpenIddictServerAspNetCoreIntegrationTests : OpenIddictServerIntegrationTests
{
public OpenIddictServerAspNetCoreIntegrationTests(ITestOutputHelper outputHelper)
: base(outputHelper)
{
}

[Fact]
public async Task ProcessChallenge_ReturnsParametersFromAuthenticationProperties()
{
Expand Down Expand Up @@ -431,6 +438,11 @@ ValueTask<OpenIddictServerIntegrationTestServer> CreateServerAsync(Action<OpenId
#endif
builder.UseEnvironment("Testing");

builder.ConfigureLogging(builder =>
{
builder.AddXUnit(OutputHelper);
});

builder.ConfigureServices(ConfigureServices);
builder.ConfigureServices(services =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<ItemGroup>
<PackageReference Include="AngleSharp" />
<PackageReference Include="MartinCostello.Logging.XUnit" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Moq" />
<PackageReference Include="System.Linq.Async" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using OpenIddict.Abstractions;
using OpenIddict.Core;
using Xunit;
using Xunit.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using static OpenIddict.Server.OpenIddictServerEvents;
using static OpenIddict.Server.OpenIddictServerHandlers;
Expand All @@ -26,6 +26,13 @@ namespace OpenIddict.Server.FunctionalTests
{
public abstract partial class OpenIddictServerIntegrationTests
{
protected OpenIddictServerIntegrationTests(ITestOutputHelper outputHelper)
{
OutputHelper = outputHelper;
}

protected ITestOutputHelper OutputHelper { get; }

[Fact]
public async Task ProcessAuthentication_UnknownEndpointCausesAnException()
{
Expand Down Expand Up @@ -4268,7 +4275,7 @@ protected OpenIddictApplicationManager<OpenIddictApplication> CreateApplicationM
var manager = new Mock<OpenIddictApplicationManager<OpenIddictApplication>>(
Mock.Of<IOpenIddictApplicationCache<OpenIddictApplication>>(),
Mock.Of<IOpenIddictApplicationStoreResolver>(),
Mock.Of<ILogger<OpenIddictApplicationManager<OpenIddictApplication>>>(),
OutputHelper.ToLogger<OpenIddictApplicationManager<OpenIddictApplication>>(),
Mock.Of<IOptionsMonitor<OpenIddictCoreOptions>>());

configuration?.Invoke(manager);
Expand All @@ -4282,7 +4289,7 @@ protected OpenIddictAuthorizationManager<OpenIddictAuthorization> CreateAuthoriz
var manager = new Mock<OpenIddictAuthorizationManager<OpenIddictAuthorization>>(
Mock.Of<IOpenIddictAuthorizationCache<OpenIddictAuthorization>>(),
Mock.Of<IOpenIddictAuthorizationStoreResolver>(),
Mock.Of<ILogger<OpenIddictAuthorizationManager<OpenIddictAuthorization>>>(),
OutputHelper.ToLogger<OpenIddictAuthorizationManager<OpenIddictAuthorization>>(),
Mock.Of<IOptionsMonitor<OpenIddictCoreOptions>>());

configuration?.Invoke(manager);
Expand All @@ -4296,7 +4303,7 @@ protected OpenIddictScopeManager<OpenIddictScope> CreateScopeManager(
var manager = new Mock<OpenIddictScopeManager<OpenIddictScope>>(
Mock.Of<IOpenIddictScopeCache<OpenIddictScope>>(),
Mock.Of<IOpenIddictScopeStoreResolver>(),
Mock.Of<ILogger<OpenIddictScopeManager<OpenIddictScope>>>(),
OutputHelper.ToLogger<OpenIddictScopeManager<OpenIddictScope>>(),
Mock.Of<IOptionsMonitor<OpenIddictCoreOptions>>());

configuration?.Invoke(manager);
Expand All @@ -4310,7 +4317,7 @@ protected OpenIddictTokenManager<OpenIddictToken> CreateTokenManager(
var manager = new Mock<OpenIddictTokenManager<OpenIddictToken>>(
Mock.Of<IOpenIddictTokenCache<OpenIddictToken>>(),
Mock.Of<IOpenIddictTokenStoreResolver>(),
Mock.Of<ILogger<OpenIddictTokenManager<OpenIddictToken>>>(),
OutputHelper.ToLogger<OpenIddictTokenManager<OpenIddictToken>>(),
Mock.Of<IOptionsMonitor<OpenIddictCoreOptions>>());

configuration?.Invoke(manager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using OpenIddict.Server.FunctionalTests;
using Owin;
using Xunit;
using Xunit.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using static OpenIddict.Server.OpenIddictServerEvents;
using static OpenIddict.Server.Owin.OpenIddictServerOwinHandlers;
Expand All @@ -27,6 +28,11 @@ namespace OpenIddict.Server.Owin.FunctionalTests
{
public partial class OpenIddictServerOwinIntegrationTests : OpenIddictServerIntegrationTests
{
public OpenIddictServerOwinIntegrationTests(ITestOutputHelper outputHelper)
: base(outputHelper)
{
}

[Fact]
public async Task ProcessChallenge_ReturnsErrorFromAuthenticationProperties()
{
Expand Down

0 comments on commit a92f48d

Please sign in to comment.