TAF.Infra.TestKit.Integration 1.0.0

dotnet add package TAF.Infra.TestKit.Integration --version 1.0.0
                    
NuGet\Install-Package TAF.Infra.TestKit.Integration -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TAF.Infra.TestKit.Integration" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TAF.Infra.TestKit.Integration" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TAF.Infra.TestKit.Integration" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TAF.Infra.TestKit.Integration --version 1.0.0
                    
#r "nuget: TAF.Infra.TestKit.Integration, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TAF.Infra.TestKit.Integration@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TAF.Infra.TestKit.Integration&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TAF.Infra.TestKit.Integration&version=1.0.0
                    
Install as a Cake Tool

TAF.Infra.TestKit.Integration

Phase-2 integration-test foundation for the TAF platform. Separate package from TAF.Infra.TestKit so unit-test-only consumers aren't forced to pull in Testcontainers/Respawn/Microsoft.AspNetCore.Mvc.Testing.

What's here

  • PostgresTestContainerFixture — starts a real, ephemeral postgres:16-alpine container via Testcontainers. Share one per test collection (ICollectionFixture<PostgresTestContainerFixture>), not per test class — container startup dominates otherwise.
  • SqlScriptRunner — applies a hand-authored schema SQL script to the container once per collection. No service in this platform has a checked-in migration/DbUp story for its own schema (it's normally produced at runtime by taf_metadataservice's DDL engine against a real tenant database) — each pilot service's integration-test project ships its own minimal schema script covering just the tables its tests touch.
  • RespawnHelper — truncates all tables back to empty between tests, without recreating the container or re-applying schema. Call ResetAsync() in a test's setup/teardown, not PostgresTestContainerFixture restart.
  • ConfigurableWebApplicationFactory<TEntryPoint> — a WebApplicationFactory that layers a flat config-override dictionary over the service's real appsettings (e.g. pointing the DB connection at the Testcontainer, switching MessageBus:Provider to InMemory, disabling ServiceAuth for tests). The service's real Program.cs runs unmodified.

Usage shape (per pilot service)

[CollectionDefinition("Postgres")]
public class PostgresCollection : ICollectionFixture<PostgresTestContainerFixture> { }

[Collection("Postgres")]
public class MyIntegrationTests : IAsyncLifetime
{
    private readonly PostgresTestContainerFixture _postgres;
    private RespawnHelper _respawn = null!;
    private ConfigurableWebApplicationFactory<Program> _factory = null!;

    public MyIntegrationTests(PostgresTestContainerFixture postgres) => _postgres = postgres;

    public async Task InitializeAsync()
    {
        await SqlScriptRunner.ApplyFileAsync(_postgres.ConnectionString, "Schema/schema.sql");
        _respawn = await RespawnHelper.CreateAsync(_postgres.ConnectionString);
        _factory = new ConfigurableWebApplicationFactory<Program>(new Dictionary<string, string?>
        {
            ["ConnectionResolver:ResolverType"] = "Config",
            // ...service-specific overrides
        });
    }

    public async Task DisposeAsync()
    {
        await _respawn.ResetAsync();
        await _factory.DisposeAsync();
    }
}

Note that a real service's Program class needs to be test-accessible — top-level statements generate an internal Program by default. Add to the service's API project:

public partial class Program { }
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 86 8/4/2026