using Heimdall.Infrastructure.Data; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace Heimdall.IntegrationTests.Factories; public class HeimdallWebApplicationFactory : WebApplicationFactory { private readonly string _dbName = $"HeimdallTestDb_{Guid.NewGuid():N}"; protected override void ConfigureWebHost(IWebHostBuilder builder) { Environment.SetEnvironmentVariable("JWT__KEY", "ThisIsATestKeyThatIsAtLeast32BytesLong!"); Environment.SetEnvironmentVariable("JWT__ISSUER", "heimdall-test"); Environment.SetEnvironmentVariable("JWT__AUDIENCE", "heimdall-test"); builder.UseEnvironment("Testing"); builder.UseSetting("Cors:AllowedOrigins", "*"); builder.ConfigureTestServices(services => { services.AddDbContext(options => { options.UseInMemoryDatabase(_dbName); }); }); } }