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
<PackageReference Include="ResQ.BuildingBlocks.Testing" Version="0.2.0" />
<PackageVersion Include="ResQ.BuildingBlocks.Testing" Version="0.2.0" />
<PackageReference Include="ResQ.BuildingBlocks.Testing" />
paket add ResQ.BuildingBlocks.Testing --version 0.2.0
#r "nuget: ResQ.BuildingBlocks.Testing, 0.2.0"
#:package ResQ.BuildingBlocks.Testing@0.2.0
#addin nuget:?package=ResQ.BuildingBlocks.Testing&version=0.2.0
#tool nuget:?package=ResQ.BuildingBlocks.Testing&version=0.2.0
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 | Versions 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. |
-
net8.0
- FluentAssertions (>= 6.12.2)
- FluentValidation (>= 11.11.0)
- FluentValidation.DependencyInjectionExtensions (>= 11.11.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- NSubstitute (>= 5.3.0)
- ResQ.BuildingBlocks.Application (>= 0.2.0)
- ResQ.BuildingBlocks.Domain (>= 0.2.0)
- Scrutor (>= 5.0.1)
- System.Text.Json (>= 9.0.19)
- xunit (>= 2.9.2)
-
net9.0
- FluentAssertions (>= 6.12.2)
- FluentValidation (>= 11.11.0)
- FluentValidation.DependencyInjectionExtensions (>= 11.11.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- NSubstitute (>= 5.3.0)
- ResQ.BuildingBlocks.Application (>= 0.2.0)
- ResQ.BuildingBlocks.Domain (>= 0.2.0)
- Scrutor (>= 5.0.1)
- System.Text.Json (>= 9.0.19)
- xunit (>= 2.9.2)
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 |