Koto.Testing
0.3.0-preview.2
This is a prerelease version of Koto.Testing.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Koto.Testing --version 0.3.0-preview.2
NuGet\Install-Package Koto.Testing -Version 0.3.0-preview.2
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="Koto.Testing" Version="0.3.0-preview.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Koto.Testing" Version="0.3.0-preview.2" />
<PackageReference Include="Koto.Testing" />
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 Koto.Testing --version 0.3.0-preview.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Koto.Testing, 0.3.0-preview.2"
#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 Koto.Testing@0.3.0-preview.2
#: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=Koto.Testing&version=0.3.0-preview.2&prerelease
#tool nuget:?package=Koto.Testing&version=0.3.0-preview.2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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> |
.Should().BeSuccess(), .BeFailure(), .BeFailureWith("code"), .HaveErrors("code1", "code2"), .HaveValue(x) |
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.invalid-length"); // all codes, in order
result.Should().HaveValue(expectedValue);
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- AwesomeAssertions (>= 9.4.0)
- Koto.Application (>= 0.3.0-preview.2)
- Koto.Domain (>= 0.3.0-preview.2)
- 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.3.0-preview.3 | 44 | 7/11/2026 |
| 0.3.0-preview.2 | 43 | 7/11/2026 |
| 0.3.0-preview.1 | 50 | 7/3/2026 |
| 0.2.0-preview.1 | 63 | 6/28/2026 |
| 0.1.0-preview.5 | 67 | 5/13/2026 |