using Testcontainers.PostgreSql; using Xunit; namespace Heimdall.TestCommon; /// /// xUnit collection fixture that manages ONE PostgreSQL Testcontainer /// for ALL database-dependent tests across test projects. /// public sealed class PostgreSqlContainerFixture : IAsyncLifetime { private readonly PostgreSqlContainer _container = new PostgreSqlBuilder("postgres:17-alpine") .WithDatabase("heimdall_test") .WithUsername("heimdall") .WithPassword("heimdall_test_pwd") .WithCleanUp(true) .Build(); public string ConnectionString => _container.GetConnectionString(); public async Task InitializeAsync() { await _container.StartAsync(); } public async Task DisposeAsync() { await _container.DisposeAsync(); } } // Collection definitions are in each test project assembly // (xUnit requires [CollectionDefinition] in the same assembly as the test).