Soenneker.Tests.FixturedUnit
11.0.2663
Prefix Reserved
dotnet add package Soenneker.Tests.FixturedUnit --version 11.0.2663
NuGet\Install-Package Soenneker.Tests.FixturedUnit -Version 11.0.2663
<PackageReference Include="Soenneker.Tests.FixturedUnit" Version="11.0.2663" />
<PackageVersion Include="Soenneker.Tests.FixturedUnit" Version="11.0.2663" />
<PackageReference Include="Soenneker.Tests.FixturedUnit" />
paket add Soenneker.Tests.FixturedUnit --version 11.0.2663
#r "nuget: Soenneker.Tests.FixturedUnit, 11.0.2663"
#:package Soenneker.Tests.FixturedUnit@11.0.2663
#addin nuget:?package=Soenneker.Tests.FixturedUnit&version=11.0.2663
#tool nuget:?package=Soenneker.Tests.FixturedUnit&version=11.0.2663
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 | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.ServiceProvider (>= 4.0.348)
- Soenneker.Fixtures.Unit (>= 11.0.810)
- Soenneker.Tests.Unit (>= 11.0.1412)
- Soenneker.Utils.BackgroundQueue (>= 11.0.2547)
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 |
|---|---|---|
| 11.0.2663 | 0 | 10/27/2026 |
| 11.0.2662 | 0 | 10/27/2026 |
| 11.0.2661 | 46 | 10/26/2026 |
| 11.0.2659 | 41 | 10/26/2026 |
| 11.0.2658 | 36 | 10/26/2026 |
| 11.0.2657 | 41 | 10/26/2026 |
| 11.0.2656 | 50 | 10/26/2026 |
| 4.0.2655 | 55 | 10/26/2026 |
| 4.0.2653 | 58 | 10/25/2026 |
| 4.0.2651 | 172 | 10/21/2026 |
| 4.0.2650 | 103 | 10/16/2026 |
| 4.0.2649 | 94 | 10/15/2026 |
| 4.0.2648 | 91 | 10/15/2026 |
| 4.0.2647 | 86 | 10/15/2026 |
| 4.0.2646 | 92 | 10/15/2026 |
| 4.0.2645 | 96 | 10/14/2026 |
| 4.0.2644 | 90 | 10/14/2026 |
| 4.0.2641 | 81 | 10/14/2026 |
| 4.0.2640 | 92 | 10/14/2026 |
| 4.0.2632 | 95 | 10/13/2026 |
Updated Soenneker.Tests.Unit to 11.0.1412