Soenneker.Tests.FixturedUnit
4.0.2528
Prefix Reserved
dotnet add package Soenneker.Tests.FixturedUnit --version 4.0.2528
NuGet\Install-Package Soenneker.Tests.FixturedUnit -Version 4.0.2528
<PackageReference Include="Soenneker.Tests.FixturedUnit" Version="4.0.2528" />
<PackageVersion Include="Soenneker.Tests.FixturedUnit" Version="4.0.2528" />
<PackageReference Include="Soenneker.Tests.FixturedUnit" />
paket add Soenneker.Tests.FixturedUnit --version 4.0.2528
#r "nuget: Soenneker.Tests.FixturedUnit, 4.0.2528"
#:package Soenneker.Tests.FixturedUnit@4.0.2528
#addin nuget:?package=Soenneker.Tests.FixturedUnit&version=4.0.2528
#tool nuget:?package=Soenneker.Tests.FixturedUnit&version=4.0.2528
Soenneker.Tests.FixturedUnit
An xUnit test base class that connects UnitFixture dependency injection, fake-data generators, injectable test logging, and background-queue draining.
Installation
dotnet add package Soenneker.Tests.FixturedUnit
Fixture setup
using Microsoft.Extensions.DependencyInjection;
using Soenneker.Fixtures.Unit;
using Xunit;
public sealed class TestFixture : UnitFixture
{
public TestFixture()
{
Services.AddSingleton<IClock, TestClock>();
Services.AddScoped<OrderService>();
}
}
[CollectionDefinition("unit")]
public sealed class UnitCollection : ICollectionFixture<TestFixture>;
Test class
using Soenneker.Tests.FixturedUnit;
using Xunit;
using Xunit.Abstractions;
[Collection("unit")]
public sealed class OrderServiceTests : FixturedUnitTest
{
public OrderServiceTests(TestFixture fixture, ITestOutputHelper output)
: base(fixture, output)
{
}
[Fact]
public async Task Creates_an_order()
{
OrderService service = Resolve<OrderService>(scoped: true);
CreateOrder request = AutoFaker.Generate<CreateOrder>();
Order result = await service.Create(request);
Assert.NotEqual(Guid.Empty, result.Id);
}
}
The constructor binds the fixture's injectable Serilog sink to the current ITestOutputHelper. Faker and AutoFaker reuse the instances owned by the fixture.
Resolution and lifecycle
Resolve<T>() resolves from the fixture's root provider. Use Resolve<T>(scoped: true) for scoped services; the first scoped resolution creates one async scope that is reused for the test and disposed with the test base. CreateScope() is idempotent while that scope exists.
The fixture must have completed InitializeAsync before services can be resolved. Registrations belong in the fixture constructor, before its provider is built.
WaitOnQueueToEmpty(cancellationToken) resolves the fixture's shared IBackgroundQueue and waits until its queued work finishes. Use a bounded cancellation token so a failed producer cannot leave a test waiting indefinitely.
Because the output sink is shared by the fixture, avoid running test classes that inject different ITestOutputHelper instances through the same fixture concurrently; the most recent injection controls where fixture logs are written.
| 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
- Soenneker.Extensions.ServiceProvider (>= 4.0.333)
- Soenneker.Fixtures.Unit (>= 4.0.746)
- Soenneker.Tests.Unit (>= 4.0.1299)
- Soenneker.Utils.BackgroundQueue (>= 4.0.2478)
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 |
|---|---|---|
| 4.0.2528 | 0 | 9/3/2026 |
| 4.0.2527 | 26 | 9/3/2026 |
| 4.0.2526 | 35 | 9/3/2026 |
| 4.0.2525 | 32 | 9/2/2026 |
| 4.0.2524 | 40 | 9/2/2026 |
| 4.0.2523 | 35 | 9/2/2026 |
| 4.0.2522 | 38 | 9/1/2026 |
| 4.0.2521 | 43 | 9/1/2026 |
| 4.0.2520 | 64 | 9/1/2026 |
| 4.0.2519 | 74 | 9/1/2026 |
| 4.0.2518 | 64 | 9/1/2026 |
| 4.0.2517 | 78 | 8/31/2026 |
| 4.0.2516 | 72 | 8/31/2026 |
| 4.0.2515 | 81 | 8/31/2026 |
| 4.0.2514 | 73 | 8/31/2026 |
| 4.0.2513 | 73 | 8/31/2026 |
| 4.0.2512 | 74 | 8/31/2026 |
| 4.0.2511 | 79 | 8/31/2026 |
| 4.0.2509 | 74 | 8/30/2026 |
| 4.0.2508 | 75 | 8/30/2026 |
Update dependency Soenneker.Tests.Unit to 4.0.1296 (#2808)