Files
Heimdall/tests/Heimdall.IntegrationTests/Factories/HeimdallWebApplicationFactory.cs
T
Arnaud Dartois da123ec544 fix(tests): InMemory DB isolation + refactor test helpers
- Fix: InMemory database name now unique per test factory instance
  (was using process-wide env var, now per-host config via UseSetting)
- Refactor: all integration tests use shared TestHelpers.CreateAdminClientAsync
- New: register-admin endpoint (test/dev only) creates Admin users directly
- New: TestHelpers.cs with extension method for admin client creation
- Cleanup: removed bootstrap template files, old Counter/Weather pages
- Cleanup: simplified app.css with MudBlazor-only styles
- Seed: demo admin + demo site created in Development mode
2026-07-17 13:15:25 +00:00

25 lines
897 B
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
namespace Heimdall.IntegrationTests.Factories;
/// <summary>
/// WebApplicationFactory for integration tests.
/// Uses unique InMemory database name per instance to prevent test pollution.
/// </summary>
public class HeimdallWebApplicationFactory : WebApplicationFactory<Program>
{
private readonly string _dbName = $"HeimdallTest_{Guid.NewGuid():N}";
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseEnvironment("Testing");
builder.UseSetting("Cors:AllowedOrigins", "*");
builder.UseSetting("InMemoryDbName", _dbName);
// JWT config
builder.UseSetting("Jwt:Key", "ThisIsATestKeyThatIsAtLeast32BytesLong!");
builder.UseSetting("Jwt:Issuer", "heimdall-test");
builder.UseSetting("Jwt:Audience", "heimdall-test");
}
}