From 09a89a34c450d666023e9f5e4cfc849c59b88622 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Fri, 17 Jul 2026 13:17:41 +0200 Subject: [PATCH] Added first unit test. --- .../ApplyFeeHandlerTests.cs | 30 ++++++++++++++++ .../FinancialApi.Application.UnitTests.csproj | 34 +++++++++++++++++++ .../a-frame-architecture.sln | 6 ++++ .../a-frame-architecture.sln.DotSettings.user | 6 +++- 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/ApplyFeeHandlerTests.cs create mode 100644 wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/FinancialApi.Application.UnitTests.csproj diff --git a/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/ApplyFeeHandlerTests.cs b/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/ApplyFeeHandlerTests.cs new file mode 100644 index 0000000..7292a17 --- /dev/null +++ b/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/ApplyFeeHandlerTests.cs @@ -0,0 +1,30 @@ +using FinancialApi.Domain; +using FluentAssertions; +using FluentAssertions.Execution; + +namespace FinancialApi.Application.UnitTests; + +public class ApplyFeeHandlerTests +{ + [Fact] + public void GivenValidAccounts_BasicFee_ShouldValidateEverything() + { + // Arrange + var command = new ApplyFeeCommand(1, 100); + var account = new Account(1, 100, "Debit"); + var destAccount = new Account(99999, 100, "Credit"); + var pair = new FeePair(account, destAccount, TimeProvider.System.GetUtcNow()); + + // Act + var intents = ApplyFeeHandler.Handle(command, pair); + + // Assert + using var _ = new AssertionScope(); + intents.CustomerWrite.Entity.Balance.Should().Be(0); + intents.RevenueWrite.Entity.Balance.Should().Be(200); + intents.RevenueWrite.Entity.Balance.Should().Be(200); + intents.JournalWrite.Entity.Lines.Count.Should().Be(2); + intents.Event.AccountId.Should().Be(account.Id); + intents.Event.Amount.Should().Be(100); + } +} \ No newline at end of file diff --git a/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/FinancialApi.Application.UnitTests.csproj b/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/FinancialApi.Application.UnitTests.csproj new file mode 100644 index 0000000..6bd4a6c --- /dev/null +++ b/wolverine/a-frame-architecture/FinancialApi.Application.UnitTests/FinancialApi.Application.UnitTests.csproj @@ -0,0 +1,34 @@ + + + + net10.0 + enable + enable + false + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\..\..\..\.nuget\packages\wolverinefx\6.18.0\lib\net10.0\Wolverine.dll + + + + \ No newline at end of file diff --git a/wolverine/a-frame-architecture/a-frame-architecture.sln b/wolverine/a-frame-architecture/a-frame-architecture.sln index 7ac1c44..8dcd001 100644 --- a/wolverine/a-frame-architecture/a-frame-architecture.sln +++ b/wolverine/a-frame-architecture/a-frame-architecture.sln @@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Infrastructure EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Domain", "FinancialApi.Domain\FinancialApi.Domain.csproj", "{2DB493D2-1C96-4F7C-9AB6-2846A92860B9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Application.UnitTests", "FinancialApi.Application.UnitTests\FinancialApi.Application.UnitTests.csproj", "{93DBA3AA-3C03-431C-A41C-DDADFAC964D5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,5 +38,9 @@ Global {2DB493D2-1C96-4F7C-9AB6-2846A92860B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {2DB493D2-1C96-4F7C-9AB6-2846A92860B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {2DB493D2-1C96-4F7C-9AB6-2846A92860B9}.Release|Any CPU.Build.0 = Release|Any CPU + {93DBA3AA-3C03-431C-A41C-DDADFAC964D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93DBA3AA-3C03-431C-A41C-DDADFAC964D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93DBA3AA-3C03-431C-A41C-DDADFAC964D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93DBA3AA-3C03-431C-A41C-DDADFAC964D5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/wolverine/a-frame-architecture/a-frame-architecture.sln.DotSettings.user b/wolverine/a-frame-architecture/a-frame-architecture.sln.DotSettings.user index 6108694..40f1a89 100644 --- a/wolverine/a-frame-architecture/a-frame-architecture.sln.DotSettings.user +++ b/wolverine/a-frame-architecture/a-frame-architecture.sln.DotSettings.user @@ -1,3 +1,7 @@  ForceIncluded - ForceIncluded \ No newline at end of file + ForceIncluded + ForceIncluded + <SessionState ContinuousTestingMode="0" IsActive="True" Name="Test1" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Solution /> +</SessionState> \ No newline at end of file