- Supprime InMemory de tous les .csproj (Infrastructure, Domain.Tests, IntegrationTests)\n- Supprime le branchement Database:Provider=InMemory de DependencyInjection.cs\n (plus que du PostgreSQL natif)\n- Infrastructure.Tests: CameraAssignment + CameraEvent tests -> Testcontainers\n- PostgreSqlContainerFixture ajoute aux Infrastructure.Tests\n- appsettings.Testing.json: retire Database:Provider et Hangfire:Enabled\n- 4 tests echouent encore: bugs pre-existants masques par InMemory\n (FK non respectees, donnees de test erronees)\n\nTests: 222/226 passed (4 pre-existants lies aux FK)
35 lines
953 B
C#
35 lines
953 B
C#
using Testcontainers.PostgreSql;
|
|
|
|
namespace Heimdall.Infrastructure.Tests;
|
|
|
|
/// <summary>
|
|
/// xUnit collection fixture that manages a PostgreSQL Testcontainer.
|
|
/// One container per test collection — shared across all test classes.
|
|
/// </summary>
|
|
public 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();
|
|
}
|
|
}
|
|
|
|
[CollectionDefinition("PostgresInfra")]
|
|
public class PostgresInfraFixture : ICollectionFixture<PostgreSqlContainerFixture>
|
|
{
|
|
}
|