Files
KArtSell.Aegis/docs/Design/kbx-foundation-v52-fe-operational-navigation-screen-anatomy/tests/backend/KbxScenarioPostgresFixture.cs
T
kjh2064 c41e5063b7 chore: remove kbx-foundation-v36 reference (superseded by v4 implementation)
Removed entire kbx-foundation-v36 directory as it's been replaced by
the new KBX Foundation v4 patterns implemented in this session:
- Registry-driven screen definitions
- Density-aware UI adapter components
- Feature module templates (ShadowRun, Models)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-12 01:39:58 +09:00

40 lines
1.5 KiB
C#

using Xunit;
using Npgsql;
using Testcontainers.PostgreSql;
namespace Kbx.Tests.Scenarios;
/// <summary>
/// Host repository reference fixture. Requires Testcontainers.PostgreSql and Npgsql.
/// The container is disposable; never point this fixture at a production connection string.
/// </summary>
public sealed class KbxScenarioPostgresFixture : IAsyncLifetime
{
private readonly PostgreSqlContainer _postgres = new PostgreSqlBuilder()
.WithImage("postgres:17-alpine")
.WithDatabase("kbx_scenario_test")
.WithUsername("kbx")
.WithPassword("kbx-test-only")
.Build();
public string ConnectionString => _postgres.GetConnectionString();
public async Task InitializeAsync()
{
await _postgres.StartAsync();
// Host: run DbUp migrations in filename order, then bootstrap/reset/seed SQL.
}
public Task DisposeAsync() => _postgres.DisposeAsync().AsTask();
public static async Task AssertTestGuardAsync(string connectionString, CancellationToken ct = default)
{
await using var connection = new NpgsqlConnection(connectionString);
await connection.OpenAsync(ct);
await using var command = new NpgsqlCommand(
"select exists(select 1 from kbx_test.environment_guard where marker='KBX_SCENARIO_TEST_ONLY')", connection);
if (await command.ExecuteScalarAsync(ct) is not true)
throw new InvalidOperationException("KBX scenario database guard is missing.");
}
}