diff --git a/eShopOnWeb.sln b/eShopOnWeb.sln index 3ffe230..769e775 100755 --- a/eShopOnWeb.sln +++ b/eShopOnWeb.sln @@ -21,6 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "tests\Fu EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0BD72BEA-EF42-4B72-8B69-12A39EC76FBA}" ProjectSection(SolutionItems) = preProject + docker-compose.override.yml = docker-compose.override.yml docker-compose.yml = docker-compose.yml README.md = README.md EndProjectSection diff --git a/src/Web/Startup.cs b/src/Web/Startup.cs index 813fc02..ddecf2e 100644 --- a/src/Web/Startup.cs +++ b/src/Web/Startup.cs @@ -123,7 +123,6 @@ namespace Microsoft.eShopWeb.Web options.Conventions.AuthorizePage("/Basket/Checkout"); }); services.AddControllersWithViews(); - services.AddControllers(); services.AddHttpContextAccessor(); diff --git a/tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs b/tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs index 4595d6c..009a665 100644 --- a/tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs +++ b/tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.eShopWeb.Web; using System; using System.Collections.Generic; using System.Linq; @@ -12,9 +11,9 @@ using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers { [Collection("Sequential")] - public class AccountControllerSignIn : IClassFixture> + public class AccountControllerSignIn : IClassFixture { - public AccountControllerSignIn(CustomWebApplicationFactory factory) + public AccountControllerSignIn(WebTestFixture factory) { Client = factory.CreateClient(new WebApplicationFactoryClientOptions { diff --git a/tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs b/tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs index d5f79a5..5349559 100644 --- a/tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs +++ b/tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs @@ -1,5 +1,4 @@ -using Microsoft.eShopWeb.Web; -using Microsoft.eShopWeb.Web.ViewModels; +using Microsoft.eShopWeb.Web.ViewModels; using Newtonsoft.Json; using System.Linq; using System.Net.Http; @@ -9,9 +8,9 @@ using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers { [Collection("Sequential")] - public class ApiCatalogControllerList : IClassFixture> + public class ApiCatalogControllerList : IClassFixture { - public ApiCatalogControllerList(CustomWebApplicationFactory factory) + public ApiCatalogControllerList(WebTestFixture factory) { Client = factory.CreateClient(); } diff --git a/tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs b/tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs index 34c03cb..5ca9958 100644 --- a/tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs +++ b/tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs @@ -1,14 +1,13 @@ -using Microsoft.eShopWeb.Web; -using System.Net.Http; +using System.Net.Http; using System.Threading.Tasks; using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers { [Collection("Sequential")] - public class CatalogControllerIndex : IClassFixture> + public class CatalogControllerIndex : IClassFixture { - public CatalogControllerIndex(CustomWebApplicationFactory factory) + public CatalogControllerIndex(WebTestFixture factory) { Client = factory.CreateClient(); } diff --git a/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs b/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs index 06aa483..3a4d7e4 100644 --- a/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs +++ b/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.eShopWeb.Web; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -8,9 +7,9 @@ using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers { [Collection("Sequential")] - public class OrderIndexOnGet : IClassFixture> + public class OrderIndexOnGet : IClassFixture { - public OrderIndexOnGet(CustomWebApplicationFactory factory) + public OrderIndexOnGet(WebTestFixture factory) { Client = factory.CreateClient(new WebApplicationFactoryClientOptions { diff --git a/tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs b/tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs index cc12b85..4afd769 100644 --- a/tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs +++ b/tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs @@ -1,9 +1,7 @@ using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.eShopWeb.FunctionalTests.Web.Controllers; -using Microsoft.eShopWeb.Web; +using Microsoft.eShopWeb.FunctionalTests.Web; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -12,9 +10,9 @@ using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages { [Collection("Sequential")] - public class BasketPageCheckout : IClassFixture> + public class BasketPageCheckout : IClassFixture { - public BasketPageCheckout(CustomWebApplicationFactory factory) + public BasketPageCheckout(WebTestFixture factory) { Client = factory.CreateClient(new WebApplicationFactoryClientOptions { diff --git a/tests/FunctionalTests/Web/Pages/HomePageOnGet.cs b/tests/FunctionalTests/Web/Pages/HomePageOnGet.cs index 73c62df..650efcb 100644 --- a/tests/FunctionalTests/Web/Pages/HomePageOnGet.cs +++ b/tests/FunctionalTests/Web/Pages/HomePageOnGet.cs @@ -1,5 +1,4 @@ -using Microsoft.eShopWeb.FunctionalTests.Web.Controllers; -using Microsoft.eShopWeb.Web; +using Microsoft.eShopWeb.FunctionalTests.Web; using System.Net.Http; using System.Threading.Tasks; using Xunit; @@ -7,9 +6,9 @@ using Xunit; namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages { [Collection("Sequential")] - public class HomePageOnGet : IClassFixture> + public class HomePageOnGet : IClassFixture { - public HomePageOnGet(CustomWebApplicationFactory factory) + public HomePageOnGet(WebTestFixture factory) { Client = factory.CreateClient(); } diff --git a/tests/FunctionalTests/Web/CustomWebApplicationFactory.cs b/tests/FunctionalTests/Web/WebTestFixture.cs similarity index 92% rename from tests/FunctionalTests/Web/CustomWebApplicationFactory.cs rename to tests/FunctionalTests/Web/WebTestFixture.cs index 1db16a3..f1c213e 100644 --- a/tests/FunctionalTests/Web/CustomWebApplicationFactory.cs +++ b/tests/FunctionalTests/Web/WebTestFixture.cs @@ -9,10 +9,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; -namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers +namespace Microsoft.eShopWeb.FunctionalTests.Web { - public class CustomWebApplicationFactory - : WebApplicationFactory + public class WebTestFixture : WebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { @@ -53,7 +52,7 @@ namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers var loggerFactory = scopedServices.GetRequiredService(); var logger = scopedServices - .GetRequiredService>>(); + .GetRequiredService>(); // Ensure the database is created. db.Database.EnsureCreated();