HerrGeneral.Testing
1.7.0
dotnet add package HerrGeneral.Testing --version 1.7.0
NuGet\Install-Package HerrGeneral.Testing -Version 1.7.0
<PackageReference Include="HerrGeneral.Testing" Version="1.7.0" />
<PackageVersion Include="HerrGeneral.Testing" Version="1.7.0" />
<PackageReference Include="HerrGeneral.Testing" />
paket add HerrGeneral.Testing --version 1.7.0
#r "nuget: HerrGeneral.Testing, 1.7.0"
#:package HerrGeneral.Testing@1.7.0
#addin nuget:?package=HerrGeneral.Testing&version=1.7.0
#tool nuget:?package=HerrGeneral.Testing&version=1.7.0
HerrGeneral.Testing
Testing utilities and fluent assertions for HerrGeneral CQRS applications and unit tests.
Installation
dotnet add package HerrGeneral.Testing
Features & Usage
1. Fluent Command Dispatch & Result Assertions
Simplify unit and integration testing of mediator commands with extension methods that automatically execute the command and assert success or return the expected value:
using HerrGeneral.Testing;
// Dispatch and assert success
await new FreezeBankAccount(accountId).AssertSendFrom(mediator);
// Dispatch creation command and retrieve the resulting value (e.g., Guid ID)
Guid accountId = await new OpenBankAccount("John Doe").AssertSendFrom<Guid>(mediator);
2. Task & Result Assertions
Assert the outcome of asynchronous command executions directly:
using HerrGeneral.Testing;
// Assert success and unwrap value
var accountId = await mediator.Send<Guid>(new OpenBankAccount("Alice")).ShouldSuccess();
// Assert success with specific value
await mediator.Send<string>(new GetStatus(accountId)).ShouldSuccessWithValue("Active");
// Assert domain errors (business rule failures)
await mediator.Send(new DebitAccount(accountId, 1000m))
.ShouldFailWithDomainErrorOfType<InsufficientFundsError>();
// Assert panic exceptions (technical exceptions)
await mediator.Send(new InvalidOperationCommand())
.ShouldFailWithPanicExceptionOfType<InvalidOperationException>();
3. xUnit Test Output Logging
Integrate Microsoft.Extensions.Logging with xUnit's ITestOutputHelper during test execution:
using HerrGeneral.Testing;
services.AddHerrGeneralTestLogger(testOutputHelper, LogLevel.Debug);
When enabled, test runs produce a structured hierarchical causal tree in test output:
CMD [OpenBankAccount] (thread #4) ................................. [OK] (8.3ms)
|
\--> (cmd) OpenBankAccountHandler (0.5ms)
|
|-- (evt) AccountOpened
| \--> (wr) CreateDebitCardOnAccountOpened (3.1ms)
| \-- (evt) DebitCardCreated
|
\== [TX COMMIT] (1.2ms)
|
+-- [SYNC PROJECTIONS] (Read-Side)
| \-- AccountOpened ===> AccountSummaryView (1.1ms)
|
\-- [POST TRANSACTION] (Side Effects & Outbox)
\-- AccountOpened ===> SendWelcomeEmailSideEffect (1.9ms)
Compatibility
- Targets
.NET 8.0,.NET 9.0, and.NET 10.0.
| Product | Versions 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. |
-
net10.0
- Divergic.Logging.Xunit (>= 4.3.1)
- HerrGeneral.Core (>= 1.7.0)
- HerrGeneral.Primitives (>= 1.7.0)
- Shouldly (>= 4.3.0)
- xunit.assert (>= 2.9.3)
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 |
|---|---|---|
| 1.7.0 | 77 | 10/7/2026 |
| 1.6.0 | 78 | 10/5/2026 |
| 1.5.1-alpha.0.30 | 55 | 10/5/2026 |