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
                    
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="Soenneker.Tests.FixturedUnit" Version="4.0.2528" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Tests.FixturedUnit" Version="4.0.2528" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Tests.FixturedUnit" />
                    
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 Soenneker.Tests.FixturedUnit --version 4.0.2528
                    
#r "nuget: Soenneker.Tests.FixturedUnit, 4.0.2528"
                    
#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 Soenneker.Tests.FixturedUnit@4.0.2528
                    
#: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=Soenneker.Tests.FixturedUnit&version=4.0.2528
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Tests.FixturedUnit&version=4.0.2528
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 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
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
Loading failed

Update dependency Soenneker.Tests.Unit to 4.0.1296 (#2808)