diff --git a/tests/SIGCM2.TestSupport/SqlTestFixture.cs b/tests/SIGCM2.TestSupport/SqlTestFixture.cs index 828bd42..e87885e 100644 --- a/tests/SIGCM2.TestSupport/SqlTestFixture.cs +++ b/tests/SIGCM2.TestSupport/SqlTestFixture.cs @@ -16,7 +16,14 @@ public sealed class SqlTestFixture : IAsyncLifetime private SqlConnection _connection = null!; private Respawner _respawner = null!; - public SqlTestFixture(string connectionString) + /// Parameterless ctor for xUnit ICollectionFixture — uses SIGCM2_Test_App. + public SqlTestFixture() : this(TestConnectionStrings.AppTestDb) { } + + /// + /// Explicit connection string ctor — used by TestWebAppFactory (same assembly). + /// Internal to satisfy xUnit's "single public constructor" rule for ICollectionFixture. + /// + internal SqlTestFixture(string connectionString) { _connectionString = connectionString; } @@ -80,6 +87,13 @@ public sealed class SqlTestFixture : IAsyncLifetime await ResetAndSeedAsync(); } + /// + /// Exposes the open SqlConnection for tests that need to run ad-hoc queries + /// (e.g. seed extra rows, assert history tables). Connection is opened during + /// InitializeAsync and closed in DisposeAsync. + /// + public SqlConnection Connection => _connection; + public async Task ResetAndSeedAsync() { await _respawner.ResetAsync(_connection); diff --git a/tests/SIGCM2.TestSupport/TestWebAppFactory.cs b/tests/SIGCM2.TestSupport/TestWebAppFactory.cs index 93cf2c0..a0e2317 100644 --- a/tests/SIGCM2.TestSupport/TestWebAppFactory.cs +++ b/tests/SIGCM2.TestSupport/TestWebAppFactory.cs @@ -13,12 +13,11 @@ namespace SIGCM2.TestSupport; /// /// WebApplicationFactory for integration tests against SIGCM2.Api. -/// Uses SIGCM2_Test database (separate from production SIGCM2). +/// Uses SIGCM2_Test_Api database (isolated from Application.Tests which uses SIGCM2_Test_App). /// public sealed class TestWebAppFactory : WebApplicationFactory, IAsyncLifetime { - private const string TestConnectionString = - "Server=TECNICA3;Database=SIGCM2_Test;User Id=desarrollo;Password=desarrollo2026;TrustServerCertificate=True;"; + private const string TestConnectionString = TestConnectionStrings.ApiTestDb; // Resolved once — absolute paths independent of working directory private static readonly string RepoRoot = ResolveRepoRoot();