23 lines
815 B
C#
23 lines
815 B
C#
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));
|
|
});
|
|
}
|
|
}
|