// ----------------------------------------------------------------------------- // PolicyPostgresFixture.cs // Sprint: SPRINT_5100_0007_0004_storage_harness // Task: STOR-HARNESS-012 // Description: Policy PostgreSQL test fixture using TestKit // ----------------------------------------------------------------------------- using System.Reflection; using StellaOps.Infrastructure.Postgres.Testing; using StellaOps.Policy.Storage.Postgres; using Xunit; // Type aliases to disambiguate TestKit and Infrastructure.Postgres.Testing fixtures using TestKitPostgresFixture = StellaOps.TestKit.Fixtures.PostgresFixture; using TestKitPostgresIsolationMode = StellaOps.TestKit.Fixtures.PostgresIsolationMode; namespace StellaOps.Policy.Storage.Postgres.Tests; /// /// PostgreSQL integration test fixture for the Policy module. /// Runs migrations from embedded resources and provides test isolation. /// public sealed class PolicyPostgresFixture : PostgresIntegrationFixture, ICollectionFixture { protected override Assembly? GetMigrationAssembly() => typeof(PolicyDataSource).Assembly; protected override string GetModuleName() => "Policy"; } /// /// Collection definition for Policy PostgreSQL integration tests. /// Tests in this collection share a single PostgreSQL container instance. /// [CollectionDefinition(Name)] public sealed class PolicyPostgresCollection : ICollectionFixture { public const string Name = "PolicyPostgres"; } /// /// TestKit-based PostgreSQL fixture for Policy storage tests. /// Uses TestKit's PostgresFixture for enhanced isolation modes. /// public sealed class PolicyTestKitPostgresFixture : IAsyncLifetime { private TestKitPostgresFixture _fixture = null!; private Assembly MigrationAssembly => typeof(PolicyDataSource).Assembly; public TestKitPostgresFixture Fixture => _fixture; public string ConnectionString => _fixture.ConnectionString; public async Task InitializeAsync() { _fixture = new TestKitPostgresFixture(TestKitPostgresIsolationMode.Truncation); await _fixture.InitializeAsync(); await _fixture.ApplyMigrationsFromAssemblyAsync(MigrationAssembly); } public Task DisposeAsync() => _fixture.DisposeAsync(); public Task TruncateAllTablesAsync() => _fixture.TruncateAllTablesAsync(); } /// /// Collection definition for Policy TestKit PostgreSQL tests. /// [CollectionDefinition(PolicyTestKitPostgresCollection.Name)] public sealed class PolicyTestKitPostgresCollection : ICollectionFixture { public const string Name = "PolicyTestKitPostgres"; }