Browse Source

Fix Multiple DbContext Registration (#703)

Hi, i noticed that in the WebTestFixture used for FunctionalTests the DbContexts were registered without removing the existing ones in Program.cs
which leads to duplication
main
Said Haouaouchi 3 years ago
committed by GitHub
parent
commit
4304545f19
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      tests/FunctionalTests/Web/WebTestFixture.cs

10
tests/FunctionalTests/Web/WebTestFixture.cs

@ -23,6 +23,16 @@ public class TestApplication : WebApplicationFactory<IBasketViewModelService>
// Add mock/test services to the builder here
builder.ConfigureServices(services =>
{
var descriptors = services.Where(d =>
d.ServiceType == typeof(DbContextOptions<CatalogContext>) ||
d.ServiceType == typeof(DbContextOptions<AppIdentityDbContext>))
.ToList();
foreach (var descriptor in descriptors)
{
services.Remove(descriptor);
}
services.AddScoped(sp =>
{
// Replace SQLite with in-memory database for tests

Loading…
Cancel
Save