using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using MinAttest.Infrastructure.Data; namespace MinAttest.Tests.Integration.Server; public class ApiWebAppFactory : WebApplicationFactory { protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder) { builder.ConfigureServices(services => { var descriptor = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions)); if (descriptor is not null) { services.Remove(descriptor); } services.AddDbContext(options => options.UseSqlServer(TestDb.ConnectionString)); }); } }