From 97af55e45a7a10b19d256cbaf0ed577207184918 Mon Sep 17 00:00:00 2001 From: Luke Latham Date: Tue, 21 Jul 2020 10:27:22 -0500 Subject: [PATCH] Update integration tests sample app (#19274) --- .../CustomWebApplicationFactory.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample/tests/RazorPagesProject.Tests/CustomWebApplicationFactory.cs b/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample/tests/RazorPagesProject.Tests/CustomWebApplicationFactory.cs index 8bedf4084c..fcfbe3e010 100644 --- a/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample/tests/RazorPagesProject.Tests/CustomWebApplicationFactory.cs +++ b/aspnetcore/test/integration-tests/samples/3.x/IntegrationTestsSample/tests/RazorPagesProject.Tests/CustomWebApplicationFactory.cs @@ -17,27 +17,19 @@ namespace RazorPagesProject.Tests { builder.ConfigureServices(services => { - // Remove the app's ApplicationDbContext registration. var descriptor = services.SingleOrDefault( d => d.ServiceType == typeof(DbContextOptions)); - if (descriptor != null) - { - services.Remove(descriptor); - } + services.Remove(descriptor); - // Add ApplicationDbContext using an in-memory database for testing. services.AddDbContext(options => { options.UseInMemoryDatabase("InMemoryDbForTesting"); }); - // Build the service provider. var sp = services.BuildServiceProvider(); - // Create a scope to obtain a reference to the database - // context (ApplicationDbContext). using (var scope = sp.CreateScope()) { var scopedServices = scope.ServiceProvider; @@ -45,12 +37,10 @@ namespace RazorPagesProject.Tests var logger = scopedServices .GetRequiredService>>(); - // Ensure the database is created. db.Database.EnsureCreated(); try { - // Seed the database with test data. Utilities.InitializeDbForTests(db); } catch (Exception ex)