Koto.Testing
0.5.0-preview.1
See the version list below for details.
dotnet add package Koto.Testing --version 0.5.0-preview.1
NuGet\Install-Package Koto.Testing -Version 0.5.0-preview.1
<PackageReference Include="Koto.Testing" Version="0.5.0-preview.1" />
<PackageVersion Include="Koto.Testing" Version="0.5.0-preview.1" />
<PackageReference Include="Koto.Testing" />
paket add Koto.Testing --version 0.5.0-preview.1
#r "nuget: Koto.Testing, 0.5.0-preview.1"
#:package Koto.Testing@0.5.0-preview.1
#addin nuget:?package=Koto.Testing&version=0.5.0-preview.1&prerelease
#tool nuget:?package=Koto.Testing&version=0.5.0-preview.1&prerelease
Koto.Testing
DDD-specific test helpers for Koto microservices.
What's included
| Type | Purpose |
|---|---|
AggregateTestFixture<TAgg> |
Fluent Given/When/Then for aggregate unit tests |
AggregateAssertions<TAgg> |
Domain event assertions |
FakeRepository<TAgg, TId> |
In-memory IRepository<TAgg,TId> |
FakeIntegrationEventPublisher |
Captures published IIntegrationEvents |
ResultAssertions<T> / AppResultAssertions<T> |
.Should().BeSuccess(), .BeFailure(), .BeFailureWith("code"), .HaveErrors("code1", "code2"), .HaveValue(x); application results also .HaveErrorForField("email") (case-insensitive: the wire name and nameof(cmd.Email) both match) |
ErrorCatalog |
Scan(assemblies) lists every error record with its code and detail keys; ShouldBeValid(assemblies) fails on malformed or duplicate codes (typed enrichments deriving from EnrichedError share their cause's code and are not duplicates) |
Aggregate unit tests
public class OrderTests
{
[Fact]
public void Cancel_raises_OrderCancelled_event()
{
new AggregateTestFixture<Order>()
.Given(new OrderPlaced(orderId, customerId))
.When(o => o.Cancel("Customer request"))
.Then()
.ShouldHaveRaisedEvent<OrderCancelled>(e => e.Reason == "Customer request")
.And.ShouldHaveRaisedExactly(1);
}
}
Result assertions
var result = order.Cancel("reason");
result.Should().BeSuccess();
result.Should().BeFailureWith("orders.order.already-cancelled");
result.Should().HaveErrors("general.value.is-required", "general.value.invalid-length"); // all codes, in order
result.Should().HaveValue(expectedValue);
// Application results (handlers) carry enriched errors:
var appResult = await handler.HandleAsync(command);
appResult.Should().BeFailureWith("general.value.is-required").And.HaveErrorForField("email");
Error catalog test
One test per service keeps the error contract honest — every record constructs, every code follows
context.entity.problem, no code is defined by two types:
[Fact]
public void Error_catalog_is_valid() =>
ErrorCatalog.ShouldBeValid(typeof(Order).Assembly, typeof(PlaceOrderHandler).Assembly);
// ErrorCatalog.Scan(...) returns (Type, Code, Message, DetailKeys) — the input for generating
// client-side types or documentation.
Fake infrastructure
var repo = new FakeRepository<Order, OrderId>();
var publisher = new FakeIntegrationEventPublisher();
// ... run use case ...
repo.All.Should().ContainSingle();
publisher.GetPublishedEvent<OrderPlacedEvent>().OrderId.Should().Be(orderId);
IAggregateApply<TEvent> (optional)
Implement on your aggregate to enable state reconstruction in Given():
public class Order : AggregateRoot<OrderId>, IAggregateApply<OrderPlaced>
{
public void Apply(OrderPlaced e) => Status = OrderStatus.Pending;
}
| 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
- AwesomeAssertions (>= 9.4.0)
- Koto.Application (>= 0.5.0-preview.1)
- Koto.Domain (>= 0.5.0-preview.1)
- xunit.abstractions (>= 2.0.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 |
|---|---|---|
| 0.5.0-preview.9 | 47 | 11/30/2026 |
| 0.5.0-preview.8 | 54 | 11/30/2026 |
| 0.5.0-preview.7 | 55 | 11/29/2026 |
| 0.5.0-preview.6 | 52 | 11/29/2026 |
| 0.5.0-preview.5 | 52 | 11/29/2026 |
| 0.5.0-preview.4 | 52 | 11/29/2026 |
| 0.5.0-preview.3 | 50 | 11/29/2026 |
| 0.5.0-preview.2 | 53 | 11/29/2026 |
| 0.5.0-preview.1 | 63 | 11/8/2026 |
| 0.4.0 | 166 | 7/21/2026 |
| 0.3.0-preview.15 | 91 | 7/21/2026 |
| 0.3.0-preview.14 | 85 | 7/21/2026 |
| 0.3.0-preview.13 | 87 | 7/21/2026 |
| 0.3.0-preview.12 | 82 | 7/21/2026 |
| 0.3.0-preview.11 | 84 | 7/21/2026 |
| 0.3.0-preview.10 | 73 | 7/21/2026 |
| 0.3.0-preview.9 | 91 | 7/21/2026 |
| 0.3.0-preview.8 | 93 | 7/21/2026 |
| 0.3.0-preview.7 | 87 | 7/21/2026 |
| 0.3.0-preview.6 | 78 | 7/20/2026 |
0.5.0-preview.1 — new error model: abstract Error catalog, AppResult for handlers, one Envelope response for every transport (ADR-026). Breaking for 0.4 consumers; migration guide: https://github.com/arigatory/Koto/blob/main/docs/migrations/0.4-to-0.5.md