Soenneker.Tests.FixturedUnit 11.0.2676

Prefix Reserved
dotnet add package Soenneker.Tests.FixturedUnit --version 11.0.2676
                    
NuGet\Install-Package Soenneker.Tests.FixturedUnit -Version 11.0.2676
                    
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="11.0.2676" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Tests.FixturedUnit" Version="11.0.2676" />
                    
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 11.0.2676
                    
#r "nuget: Soenneker.Tests.FixturedUnit, 11.0.2676"
                    
#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@11.0.2676
                    
#: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=11.0.2676
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Tests.FixturedUnit&version=11.0.2676
                    
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 net11.0 is compatible. 
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
11.0.2676 45 11/7/2026
11.0.2675 55 11/6/2026
11.0.2674 65 11/4/2026
11.0.2673 54 11/4/2026
11.0.2672 71 11/3/2026
11.0.2671 86 11/3/2026
11.0.2670 81 11/3/2026
11.0.2669 84 11/3/2026
11.0.2668 82 11/3/2026
11.0.2667 89 11/2/2026
11.0.2666 86 11/2/2026
11.0.2665 97 11/2/2026
11.0.2664 104 10/29/2026
11.0.2663 102 10/27/2026
11.0.2662 98 10/27/2026
11.0.2661 105 10/26/2026
11.0.2659 96 10/26/2026
11.0.2658 84 10/26/2026
11.0.2657 88 10/26/2026
11.0.2656 98 10/26/2026
Loading failed

Update dependency Soenneker.Tests.Unit to 11.0.1424 (#2921)