RepletoryLib.Testing.Fixtures 1.0.0

dotnet add package RepletoryLib.Testing.Fixtures --version 1.0.0
                    
NuGet\Install-Package RepletoryLib.Testing.Fixtures -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="RepletoryLib.Testing.Fixtures" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RepletoryLib.Testing.Fixtures" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RepletoryLib.Testing.Fixtures" />
                    
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 RepletoryLib.Testing.Fixtures --version 1.0.0
                    
#r "nuget: RepletoryLib.Testing.Fixtures, 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 RepletoryLib.Testing.Fixtures@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=RepletoryLib.Testing.Fixtures&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RepletoryLib.Testing.Fixtures&version=1.0.0
                    
Install as a Cake Tool

RepletoryLib.Testing.Fixtures

Integration testing infrastructure with Testcontainers for SQL Server, PostgreSQL, Redis, and RabbitMQ.

Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.

NuGet .NET 10 License: MIT


Overview

RepletoryLib.Testing.Fixtures provides Testcontainer-based fixtures for integration testing. Each fixture manages a real Docker container (SQL Server, PostgreSQL, Redis, or RabbitMQ) and exposes the connection string for use in tests. The FullStackFixture starts all containers in parallel for full-stack integration testing.

Key Features

  • SqlServerFixture -- SQL Server 2022 container
  • PostgresFixture -- PostgreSQL 16 container
  • RedisFixture -- Redis 7 container
  • RabbitMqFixture -- RabbitMQ 3 container with management UI
  • FullStackFixture -- All containers started in parallel
  • IntegrationTestBase -- Combines TestBase mocks with real infrastructure
  • xUnit integration -- IAsyncLifetime for automatic container lifecycle

Installation

dotnet add package RepletoryLib.Testing.Fixtures

Dependencies

Package Type
RepletoryLib.Testing RepletoryLib
Testcontainers NuGet (4.2.0)
Testcontainers.MsSql NuGet (4.2.0)
Testcontainers.PostgreSql NuGet (4.2.0)
Testcontainers.Redis NuGet (4.2.0)
Testcontainers.RabbitMq NuGet (4.2.0)

Prerequisites

  • Docker must be running on the host machine

Usage Examples

Single Fixture (SQL Server Only)

using RepletoryLib.Testing.Fixtures;

public class OrderRepositoryTests : IClassFixture<SqlServerFixture>
{
    private readonly SqlServerFixture _fixture;

    public OrderRepositoryTests(SqlServerFixture fixture) => _fixture = fixture;

    [Fact]
    public async Task Can_persist_and_retrieve_order()
    {
        var options = new DbContextOptionsBuilder<AppDbContext>()
            .UseSqlServer(_fixture.ConnectionString)
            .Options;

        using var context = new AppDbContext(options);
        await context.Database.EnsureCreatedAsync();

        context.Orders.Add(new Order { Total = 100m });
        await context.SaveChangesAsync();

        var orders = await context.Orders.ToListAsync();
        orders.Should().HaveCount(1);
    }
}

Full Stack Integration Test

using RepletoryLib.Testing.Fixtures;

public class OrderWorkflowTests : IntegrationTestBase, IClassFixture<FullStackFixture>
{
    public OrderWorkflowTests(FullStackFixture fixture) : base(fixture) { }

    protected override void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<AppDbContext>(options =>
            options.UseSqlServer(SqlServerConnectionString));
    }

    [Fact]
    public async Task Complete_order_workflow()
    {
        MockUser.UserId = "user-001";
        MockDateTime.SetUtcNow(new DateTime(2025, 6, 15));

        var provider = BuildServiceProvider();
        var db = provider.GetRequiredService<AppDbContext>();
        await db.Database.EnsureCreatedAsync();

        // Test against real SQL Server, mocked cache/messaging
        db.Orders.Add(new Order { Total = 250m });
        await db.SaveChangesAsync();

        var count = await db.Orders.CountAsync();
        count.Should().Be(1);
    }
}

Available Connection Strings in IntegrationTestBase

Property Source
SqlServerConnectionString SqlServerFixture
PostgresConnectionString PostgresFixture
RedisConnectionString RedisFixture
RabbitMqConnectionString RabbitMqFixture
RabbitMqManagementUrl RabbitMqFixture (HTTP management UI)

Individual Fixtures

// Redis only
public class CacheTests : IClassFixture<RedisFixture>
{
    public CacheTests(RedisFixture fixture) { }
}

// PostgreSQL only
public class PgTests : IClassFixture<PostgresFixture>
{
    public PgTests(PostgresFixture fixture) { }
}

// RabbitMQ only
public class MessagingTests : IClassFixture<RabbitMqFixture>
{
    public MessagingTests(RabbitMqFixture fixture) { }
}

Container Images

Fixture Docker Image
SqlServerFixture mcr.microsoft.com/mssql/server:2022-latest
PostgresFixture postgres:16-alpine
RedisFixture redis:7-alpine
RabbitMqFixture rabbitmq:3-management-alpine

API Reference

FullStackFixture

Property Type Description
SqlServer SqlServerFixture SQL Server fixture instance
Postgres PostgresFixture PostgreSQL fixture instance
Redis RedisFixture Redis fixture instance
RabbitMq RabbitMqFixture RabbitMQ fixture instance
SqlServerConnectionString string SQL Server connection string
PostgresConnectionString string PostgreSQL connection string
RedisConnectionString string Redis connection string
RabbitMqConnectionString string RabbitMQ AMQP connection string
RabbitMqManagementUrl string RabbitMQ management HTTP URL

All containers start in parallel via Task.WhenAll() and stop in parallel during disposal.


Integration with Other RepletoryLib Packages

Package Relationship
RepletoryLib.Testing Extends TestBase with real infrastructure
RepletoryLib.Caching.Redis Test against real Redis
RepletoryLib.Messaging.RabbitMQ Test against real RabbitMQ
RepletoryLib.Data.EntityFramework Test against real SQL Server / PostgreSQL

Troubleshooting

Issue Solution
Container fails to start Ensure Docker is running and has sufficient resources
Timeout waiting for container Increase test timeout. First run downloads images which can be slow.
Port conflicts Testcontainers uses random ports. Conflicts should not occur.
Tests slow on first run Docker image pulls are cached after the first run

License

This project is licensed under the MIT License.

Copyright (c) 2024-2026 Repletory.


For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 51 3/2/2026