Skip to content

Commit fa8839e

Browse files
authored
Minor 3.x Updates (dotnet-architecture#339)
* remove unnecessary call * Refactoring test fixture
1 parent e53117b commit fa8839e

9 files changed

+20
-28
lines changed

eShopOnWeb.sln

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "tests\Fu
2121
EndProject
2222
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0BD72BEA-EF42-4B72-8B69-12A39EC76FBA}"
2323
ProjectSection(SolutionItems) = preProject
24+
docker-compose.override.yml = docker-compose.override.yml
2425
docker-compose.yml = docker-compose.yml
2526
README.md = README.md
2627
EndProjectSection

src/Web/Startup.cs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public void ConfigureServices(IServiceCollection services)
123123
options.Conventions.AuthorizePage("/Basket/Checkout");
124124
});
125125
services.AddControllersWithViews();
126-
services.AddControllers();
127126

128127
services.AddHttpContextAccessor();
129128

tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Mvc.Testing;
2-
using Microsoft.eShopWeb.Web;
32
using System;
43
using System.Collections.Generic;
54
using System.Linq;
@@ -12,9 +11,9 @@
1211
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
1312
{
1413
[Collection("Sequential")]
15-
public class AccountControllerSignIn : IClassFixture<CustomWebApplicationFactory<Startup>>
14+
public class AccountControllerSignIn : IClassFixture<WebTestFixture>
1615
{
17-
public AccountControllerSignIn(CustomWebApplicationFactory<Startup> factory)
16+
public AccountControllerSignIn(WebTestFixture factory)
1817
{
1918
Client = factory.CreateClient(new WebApplicationFactoryClientOptions
2019
{

tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Microsoft.eShopWeb.Web;
2-
using Microsoft.eShopWeb.Web.ViewModels;
1+
using Microsoft.eShopWeb.Web.ViewModels;
32
using Newtonsoft.Json;
43
using System.Linq;
54
using System.Net.Http;
@@ -9,9 +8,9 @@
98
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
109
{
1110
[Collection("Sequential")]
12-
public class ApiCatalogControllerList : IClassFixture<CustomWebApplicationFactory<Startup>>
11+
public class ApiCatalogControllerList : IClassFixture<WebTestFixture>
1312
{
14-
public ApiCatalogControllerList(CustomWebApplicationFactory<Startup> factory)
13+
public ApiCatalogControllerList(WebTestFixture factory)
1514
{
1615
Client = factory.CreateClient();
1716
}

tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
using Microsoft.eShopWeb.Web;
2-
using System.Net.Http;
1+
using System.Net.Http;
32
using System.Threading.Tasks;
43
using Xunit;
54

65
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
76
{
87
[Collection("Sequential")]
9-
public class CatalogControllerIndex : IClassFixture<CustomWebApplicationFactory<Startup>>
8+
public class CatalogControllerIndex : IClassFixture<WebTestFixture>
109
{
11-
public CatalogControllerIndex(CustomWebApplicationFactory<Startup> factory)
10+
public CatalogControllerIndex(WebTestFixture factory)
1211
{
1312
Client = factory.CreateClient();
1413
}

tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Mvc.Testing;
2-
using Microsoft.eShopWeb.Web;
32
using System.Net;
43
using System.Net.Http;
54
using System.Threading.Tasks;
@@ -8,9 +7,9 @@
87
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
98
{
109
[Collection("Sequential")]
11-
public class OrderIndexOnGet : IClassFixture<CustomWebApplicationFactory<Startup>>
10+
public class OrderIndexOnGet : IClassFixture<WebTestFixture>
1211
{
13-
public OrderIndexOnGet(CustomWebApplicationFactory<Startup> factory)
12+
public OrderIndexOnGet(WebTestFixture factory)
1413
{
1514
Client = factory.CreateClient(new WebApplicationFactoryClientOptions
1615
{

tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using Microsoft.AspNetCore.Mvc.Testing;
2-
using Microsoft.eShopWeb.FunctionalTests.Web.Controllers;
3-
using Microsoft.eShopWeb.Web;
2+
using Microsoft.eShopWeb.FunctionalTests.Web;
43
using System.Collections.Generic;
54
using System.Linq;
6-
using System.Net;
75
using System.Net.Http;
86
using System.Text.RegularExpressions;
97
using System.Threading.Tasks;
@@ -12,9 +10,9 @@
1210
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages
1311
{
1412
[Collection("Sequential")]
15-
public class BasketPageCheckout : IClassFixture<CustomWebApplicationFactory<Startup>>
13+
public class BasketPageCheckout : IClassFixture<WebTestFixture>
1614
{
17-
public BasketPageCheckout(CustomWebApplicationFactory<Startup> factory)
15+
public BasketPageCheckout(WebTestFixture factory)
1816
{
1917
Client = factory.CreateClient(new WebApplicationFactoryClientOptions
2018
{

tests/FunctionalTests/Web/Pages/HomePageOnGet.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using Microsoft.eShopWeb.FunctionalTests.Web.Controllers;
2-
using Microsoft.eShopWeb.Web;
1+
using Microsoft.eShopWeb.FunctionalTests.Web;
32
using System.Net.Http;
43
using System.Threading.Tasks;
54
using Xunit;
65

76
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages
87
{
98
[Collection("Sequential")]
10-
public class HomePageOnGet : IClassFixture<CustomWebApplicationFactory<Startup>>
9+
public class HomePageOnGet : IClassFixture<WebTestFixture>
1110
{
12-
public HomePageOnGet(CustomWebApplicationFactory<Startup> factory)
11+
public HomePageOnGet(WebTestFixture factory)
1312
{
1413
Client = factory.CreateClient();
1514
}

tests/FunctionalTests/Web/CustomWebApplicationFactory.cs tests/FunctionalTests/Web/WebTestFixture.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
using Microsoft.Extensions.Logging;
1010
using System;
1111

12-
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
12+
namespace Microsoft.eShopWeb.FunctionalTests.Web
1313
{
14-
public class CustomWebApplicationFactory<TStartup>
15-
: WebApplicationFactory<Startup>
14+
public class WebTestFixture : WebApplicationFactory<Startup>
1615
{
1716
protected override void ConfigureWebHost(IWebHostBuilder builder)
1817
{
@@ -53,7 +52,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
5352
var loggerFactory = scopedServices.GetRequiredService<ILoggerFactory>();
5453

5554
var logger = scopedServices
56-
.GetRequiredService<ILogger<CustomWebApplicationFactory<TStartup>>>();
55+
.GetRequiredService<ILogger<WebTestFixture>>();
5756

5857
// Ensure the database is created.
5958
db.Database.EnsureCreated();

0 commit comments

Comments
 (0)