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
<PackageReference Include="RepletoryLib.Testing.Fixtures" Version="1.0.0" />
<PackageVersion Include="RepletoryLib.Testing.Fixtures" Version="1.0.0" />
<PackageReference Include="RepletoryLib.Testing.Fixtures" />
paket add RepletoryLib.Testing.Fixtures --version 1.0.0
#r "nuget: RepletoryLib.Testing.Fixtures, 1.0.0"
#:package RepletoryLib.Testing.Fixtures@1.0.0
#addin nuget:?package=RepletoryLib.Testing.Fixtures&version=1.0.0
#tool nuget:?package=RepletoryLib.Testing.Fixtures&version=1.0.0
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.
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 containerPostgresFixture-- PostgreSQL 16 containerRedisFixture-- Redis 7 containerRabbitMqFixture-- RabbitMQ 3 container with management UIFullStackFixture-- All containers started in parallelIntegrationTestBase-- CombinesTestBasemocks with real infrastructure- xUnit integration --
IAsyncLifetimefor 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 | Versions 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. |
-
net10.0
- RepletoryLib.Testing (>= 1.0.0)
- Testcontainers (>= 4.2.0)
- Testcontainers.MsSql (>= 4.2.0)
- Testcontainers.PostgreSql (>= 4.2.0)
- Testcontainers.RabbitMq (>= 4.2.0)
- Testcontainers.Redis (>= 4.2.0)
- xunit (>= 2.9.3)
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 |