Part 10 · 1 chapters · ~8 min

Capstone: The Ledger API in C#

The shared ledger API capstone in C# with ASP.NET Core minimal APIs, EF Core and MassTransit: idempotent transfers under 100 concurrent requests, double-entry postings summing to zero, payouts with unknown outcomes via the outbox, and a comparison with the Java and Kotlin capstones.

11

Acceptance

code
dotnet test --filter Category=Acceptance
#  ✓ 100 concurrent identical POST /v1/transfers → exactly 1 transfer (WebApplicationFactory + Testcontainers)
#  ✓ Σ postings = 0 for every transfer (FsCheck property, 1,000 cases)
#  ✓ payout timed out at the rail → Unknown → only a rail confirmation settles it

// property test with FsCheck
[Property] public bool Postings_sum_to_zero(PositiveInt amount, NonNegativeInt fee) =>
    Ledger.PostingsFor(new Kobo(amount.Get), new Kobo(fee.Get % 5_000)).Sum(p => p.Amount.Value) == 0;
CAPSTONE: THE LEDGER API IN C#
the shared acceptance tests from every language course
idempotency100 concurrent identical requestsproduce exactly one transfer.double entryPostings for every transfer sum tozero.unknown outcomesA timed-out payout never completeswithout rail confirmation.minimal API + EF CoreNpgsql, FOR UPDATE on balances,xmin tokens.MassTransitPayout submission via the outboxand a consumer with retries.compareSame tests as Java and Kotlin:compare code and throughput.
swipe the figure sideways, or tap expand for full screen
1/4
shared contract
The same three acceptance tests as every language capstone, run through WebApplicationFactory against a Testcontainers Postgres.
the shared testsreal Postgres