Initial import
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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<Program>
|
||||
{
|
||||
protected override void ConfigureWebHost(Microsoft.AspNetCore.Hosting.IWebHostBuilder builder)
|
||||
{
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
var descriptor = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions<AppDbContext>));
|
||||
if (descriptor is not null)
|
||||
{
|
||||
services.Remove(descriptor);
|
||||
}
|
||||
services.AddDbContext<AppDbContext>(options => options.UseSqlServer(TestDb.ConnectionString));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user