ResQ.BuildingBlocks.Testing 0.2.0

dotnet add package ResQ.BuildingBlocks.Testing --version 0.2.0
                    
NuGet\Install-Package ResQ.BuildingBlocks.Testing -Version 0.2.0
                    
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="ResQ.BuildingBlocks.Testing" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ResQ.BuildingBlocks.Testing" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ResQ.BuildingBlocks.Testing" />
                    
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 ResQ.BuildingBlocks.Testing --version 0.2.0
                    
#r "nuget: ResQ.BuildingBlocks.Testing, 0.2.0"
                    
#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 ResQ.BuildingBlocks.Testing@0.2.0
                    
#: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=ResQ.BuildingBlocks.Testing&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ResQ.BuildingBlocks.Testing&version=0.2.0
                    
Install as a Cake Tool

ResQ.BuildingBlocks.Testing

Lightweight, in-memory test doubles for the ResQ building blocks. No Docker, no WebApplicationFactory, no ASP.NET framework reference — safe to add to any unit-test project. (The heavy Docker / WebApplicationFactory helpers live in ResQ.BuildingBlocks.Testing.Integration.)

Targets net8.0 and net9.0. Depends on ResQ.BuildingBlocks.Application + ResQ.BuildingBlocks.Domain, and brings xunit, FluentAssertions, and NSubstitute for consumers.

What's in the box

Type Replaces / role
FakeClock Deterministic IClock you Set/Advance by hand
NoopUnitOfWork IUnitOfWork that does nothing, returns 0
FakeUnitOfWork IUnitOfWork that counts saves and returns AffectedRows
ThrowingUnitOfWork IUnitOfWork whose SaveChangesAsync always fails
RecordingDomainEventDispatcher Captures dispatched IDomainEvents in Dispatched
RecordingIntegrationEventPublisher Captures published IntegrationEvents in Published
Builder<T> Base class for fluent test-data builders (implicit T conversion)
CapturingLoggerProvider Captures formatted log lines in Entries
XUnitLoggerProvider Forwards logs to an ITestOutputHelper
HexagonRules Dependency-rule data for your NetArchTest assertions
AddTestDoubles() One call to swap the four driven ports for the doubles above

Quick start

using Microsoft.Extensions.DependencyInjection;
using ResQ.BuildingBlocks.Testing;

var services = new ServiceCollection();
// ... register the system under test ...
services.AddTestDoubles();               // swaps IClock, IUnitOfWork, dispatcher, publisher

var provider = services.BuildServiceProvider();
var clock = (FakeClock)provider.GetRequiredService<IClock>();
clock.Advance(TimeSpan.FromHours(1));    // time is now deterministic

var publisher = (RecordingIntegrationEventPublisher)provider.GetRequiredService<IIntegrationEventPublisher>();
// ... exercise the SUT ...
publisher.Published.Should().ContainSingle();

A fluent builder

public sealed class WidgetBuilder : Builder<Widget>
{
    private string _name = "default";
    public WidgetBuilder Named(string name) { _name = name; return this; }
    public override Widget Build() => new(_name);
}

Widget widget = new WidgetBuilder().Named("gadget"); // implicit Build()

Architecture rule data

foreach (var (inner, mustNotDependOn) in HexagonRules.DependencyRule)
{
    // feed `inner` / `mustNotDependOn` into NetArchTest in your own arch-test project
}

License

Apache-2.0. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on ResQ.BuildingBlocks.Testing:

Package Downloads
ResQ.BuildingBlocks.Testing.Integration

Docker-backed integration-test helpers for the ResQ building blocks: a Testcontainers PostgreSQL fixture, an xUnit database collection, and a ResqWebApplicationFactory over Microsoft.AspNetCore.Mvc.Testing. Isolated from ResQ.BuildingBlocks.Testing so unit-only consumers do not drag in Docker or ASP.NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 233 8/16/2026