Soenneker.Tests.FixturedUnit 4.0.2525

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Tests.FixturedUnit --version 4.0.2525
                    
NuGet\Install-Package Soenneker.Tests.FixturedUnit -Version 4.0.2525
                    
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.2525" />
                    
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.2525" />
                    
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.2525
                    
#r "nuget: Soenneker.Tests.FixturedUnit, 4.0.2525"
                    
#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.2525
                    
#: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.2525
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Tests.FixturedUnit&version=4.0.2525
                    
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.2590 37 9/16/2026
4.0.2588 33 9/16/2026
4.0.2587 42 9/16/2026
4.0.2586 46 9/16/2026
4.0.2585 40 9/16/2026
4.0.2583 49 9/15/2026
4.0.2582 39 9/15/2026
4.0.2581 61 9/15/2026
4.0.2580 74 9/14/2026
4.0.2579 85 9/14/2026
4.0.2578 89 9/13/2026
4.0.2577 77 9/13/2026
4.0.2576 79 9/13/2026
4.0.2575 74 9/13/2026
4.0.2574 86 9/13/2026
4.0.2572 88 9/13/2026
4.0.2571 87 9/13/2026
4.0.2570 84 9/13/2026
4.0.2569 85 9/12/2026
4.0.2525 94 9/2/2026
Loading failed

Update dependency Soenneker.Fixtures.Unit to 4.0.744 (#2807)