add tests

This commit is contained in:
Oli Sturm
2026-04-21 15:27:03 +01:00
parent 3e9f0b56c9
commit 62ced3935c
7 changed files with 226 additions and 1 deletions
+2 -1
View File
@@ -27,8 +27,9 @@ public sealed class Account : AggregateRoot<AccountId>
if (amount.Amount <= 0)
throw new InvalidOperationException("Withdrawal amount must be positive.");
// Sometimes, validation is modelled with custom exceptions instead
if (Balance.Amount - amount.Amount < 0)
throw new InvalidOperationException("Balance cannot go below zero.");
throw new InsufficientBalanceException(Balance, amount);
Balance = Balance.Subtract(amount);
}