Browse Source

Minor 3.x Updates (#339)

* remove unnecessary call

* Refactoring test fixture
main
Steve Smith 6 years ago
committed by GitHub
parent
commit
fa8839e1d8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      eShopOnWeb.sln
  2. 1
      src/Web/Startup.cs
  3. 5
      tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs
  4. 7
      tests/FunctionalTests/Web/Controllers/ApiCatalogControllerList.cs
  5. 7
      tests/FunctionalTests/Web/Controllers/CatalogControllerIndex.cs
  6. 5
      tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs
  7. 8
      tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs
  8. 7
      tests/FunctionalTests/Web/Pages/HomePageOnGet.cs
  9. 7
      tests/FunctionalTests/Web/WebTestFixture.cs

1
eShopOnWeb.sln

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

1
src/Web/Startup.cs

@ -123,7 +123,6 @@ namespace Microsoft.eShopWeb.Web
options.Conventions.AuthorizePage("/Basket/Checkout"); options.Conventions.AuthorizePage("/Basket/Checkout");
}); });
services.AddControllersWithViews(); services.AddControllersWithViews();
services.AddControllers();
services.AddHttpContextAccessor(); services.AddHttpContextAccessor();

5
tests/FunctionalTests/Web/Controllers/AccountControllerSignIn.cs

@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb.Web;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,9 +11,9 @@ using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class AccountControllerSignIn : IClassFixture<CustomWebApplicationFactory<Startup>> public class AccountControllerSignIn : IClassFixture<WebTestFixture>
{ {
public AccountControllerSignIn(CustomWebApplicationFactory<Startup> factory) public AccountControllerSignIn(WebTestFixture factory)
{ {
Client = factory.CreateClient(new WebApplicationFactoryClientOptions Client = factory.CreateClient(new WebApplicationFactoryClientOptions
{ {

7
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 Newtonsoft.Json;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
@ -9,9 +8,9 @@ using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class ApiCatalogControllerList : IClassFixture<CustomWebApplicationFactory<Startup>> public class ApiCatalogControllerList : IClassFixture<WebTestFixture>
{ {
public ApiCatalogControllerList(CustomWebApplicationFactory<Startup> factory) public ApiCatalogControllerList(WebTestFixture factory)
{ {
Client = factory.CreateClient(); Client = factory.CreateClient();
} }

7
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 System.Threading.Tasks;
using Xunit; using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class CatalogControllerIndex : IClassFixture<CustomWebApplicationFactory<Startup>> public class CatalogControllerIndex : IClassFixture<WebTestFixture>
{ {
public CatalogControllerIndex(CustomWebApplicationFactory<Startup> factory) public CatalogControllerIndex(WebTestFixture factory)
{ {
Client = factory.CreateClient(); Client = factory.CreateClient();
} }

5
tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs

@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb.Web;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,9 +7,9 @@ using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class OrderIndexOnGet : IClassFixture<CustomWebApplicationFactory<Startup>> public class OrderIndexOnGet : IClassFixture<WebTestFixture>
{ {
public OrderIndexOnGet(CustomWebApplicationFactory<Startup> factory) public OrderIndexOnGet(WebTestFixture factory)
{ {
Client = factory.CreateClient(new WebApplicationFactoryClientOptions Client = factory.CreateClient(new WebApplicationFactoryClientOptions
{ {

8
tests/FunctionalTests/Web/Pages/BasketPageCheckout.cs

@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.eShopWeb.FunctionalTests.Web.Controllers; using Microsoft.eShopWeb.FunctionalTests.Web;
using Microsoft.eShopWeb.Web;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -12,9 +10,9 @@ using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class BasketPageCheckout : IClassFixture<CustomWebApplicationFactory<Startup>> public class BasketPageCheckout : IClassFixture<WebTestFixture>
{ {
public BasketPageCheckout(CustomWebApplicationFactory<Startup> factory) public BasketPageCheckout(WebTestFixture factory)
{ {
Client = factory.CreateClient(new WebApplicationFactoryClientOptions Client = factory.CreateClient(new WebApplicationFactoryClientOptions
{ {

7
tests/FunctionalTests/Web/Pages/HomePageOnGet.cs

@ -1,5 +1,4 @@
using Microsoft.eShopWeb.FunctionalTests.Web.Controllers; using Microsoft.eShopWeb.FunctionalTests.Web;
using Microsoft.eShopWeb.Web;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
@ -7,9 +6,9 @@ using Xunit;
namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages namespace Microsoft.eShopWeb.FunctionalTests.WebRazorPages
{ {
[Collection("Sequential")] [Collection("Sequential")]
public class HomePageOnGet : IClassFixture<CustomWebApplicationFactory<Startup>> public class HomePageOnGet : IClassFixture<WebTestFixture>
{ {
public HomePageOnGet(CustomWebApplicationFactory<Startup> factory) public HomePageOnGet(WebTestFixture factory)
{ {
Client = factory.CreateClient(); Client = factory.CreateClient();
} }

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

@ -9,10 +9,9 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers namespace Microsoft.eShopWeb.FunctionalTests.Web
{ {
public class CustomWebApplicationFactory<TStartup> public class WebTestFixture : WebApplicationFactory<Startup>
: WebApplicationFactory<Startup>
{ {
protected override void ConfigureWebHost(IWebHostBuilder builder) protected override void ConfigureWebHost(IWebHostBuilder builder)
{ {
@ -53,7 +52,7 @@ namespace Microsoft.eShopWeb.FunctionalTests.Web.Controllers
var loggerFactory = scopedServices.GetRequiredService<ILoggerFactory>(); var loggerFactory = scopedServices.GetRequiredService<ILoggerFactory>();
var logger = scopedServices var logger = scopedServices
.GetRequiredService<ILogger<CustomWebApplicationFactory<TStartup>>>(); .GetRequiredService<ILogger<WebTestFixture>>();
// Ensure the database is created. // Ensure the database is created.
db.Database.EnsureCreated(); db.Database.EnsureCreated();
Loading…
Cancel
Save