TheMagnificent11 / lewee

2 stars 1 forks source link

Fix `Lewee.IntegrationTests.HostedApplicationTests` #200

Open TheMagnificent11 opened 2 months ago

TheMagnificent11 commented 2 months ago

Perhaps replace WebApplicationFactory with TestServer in WebApiIntegrationTests as WebApplicationFactory seems to have MVC in the pipeline (based on the namespace).

Potential way to replace it.

var hostBuilder = new HostBuilder()
    .ConfigureWebHost(webHost =>
    {
        webHost.UseTestServer();
        webHost.UseStartup<Program>(); // Entry point class
    });

var host = hostBuilder.Start();

// Get your DbContext
var dbContext = host.Services.GetRequiredService<YourDbContext>();

// Use dbContext to seed data or verify data