Skip to content

Commit

Permalink
Extract base class for IClassFixture for STS
Browse files Browse the repository at this point in the history
  • Loading branch information
skoruba committed Oct 5, 2019
1 parent c4a6e6c commit a1f699e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using HtmlAgilityPack;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Mocks;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class AccountControllerTests : IClassFixture<WebApplicationFactory<Startup>>
public class AccountControllerTests : BaseClassFixture
{
private readonly HttpClient _client;

public AccountControllerTests(WebApplicationFactory<Startup> factory)
public AccountControllerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Net.Http;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base
{
public class BaseClassFixture : IClassFixture<WebApplicationFactory<Startup>>
{
protected readonly HttpClient _client;

public BaseClassFixture(WebApplicationFactory<Startup> factory)
{
_client = factory.SetupClient();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class DiagnosticsControllerTests : IClassFixture<WebApplicationFactory<Startup>>
public class DiagnosticsControllerTests : BaseClassFixture
{
private readonly HttpClient _client;

public DiagnosticsControllerTests(WebApplicationFactory<Startup> factory)
public DiagnosticsControllerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Mocks;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class GrantsControllerTests : IClassFixture<WebApplicationFactory<Startup>>
public class GrantsControllerTests : BaseClassFixture
{
private readonly HttpClient _client;

public GrantsControllerTests(WebApplicationFactory<Startup> factory)
public GrantsControllerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class HomeControllerTests : IClassFixture<WebApplicationFactory<Startup>>
public class HomeControllerTests : BaseClassFixture
{
private readonly HttpClient _client;

public HomeControllerTests(WebApplicationFactory<Startup> factory)
public HomeControllerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading.Tasks;
using FluentAssertions;
using IdentityModel.Client;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class IdentityServerTests : IClassFixture<WebApplicationFactory<Startup>>
public class IdentityServerTests : BaseClassFixture
{
private readonly HttpClient _client;

public IdentityServerTests(WebApplicationFactory<Startup> factory)
public IdentityServerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
public async Task CanShowDiscoveryEndpoint()
{
var disco = await _client.GetDiscoveryDocumentAsync("http://localhost");

disco.Should().NotBeNull();
disco.IsError.Should().Be(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Common;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Mocks;
using Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests.Base;
using Xunit;

namespace Skoruba.IdentityServer4.STS.Identity.IntegrationTests.Tests
{
public class ManageControllerTests : IClassFixture<WebApplicationFactory<Startup>>
public class ManageControllerTests : BaseClassFixture
{
private readonly HttpClient _client;

public ManageControllerTests(WebApplicationFactory<Startup> factory)
public ManageControllerTests(WebApplicationFactory<Startup> factory) : base(factory)
{
_client = factory.SetupClient();
}

[Fact]
Expand Down

0 comments on commit a1f699e

Please sign in to comment.