Koto.Testing 0.1.0-preview.5

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

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"), .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().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 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.

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.1.0-preview.5 36 5/13/2026