Added first unit test.

This commit is contained in:
2026-07-17 13:17:41 +02:00
parent d77e575c00
commit 09a89a34c4
4 changed files with 75 additions and 1 deletions
@@ -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);
}
}
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
<PackageReference Include="FluentAssertions" Version="8.10.0" />
<PackageReference Include="JasperFx" Version="2.27.0" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"/>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FinancialApi.Application\FinancialApi.Application.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Wolverine">
<HintPath>..\..\..\..\..\..\.nuget\packages\wolverinefx\6.18.0\lib\net10.0\Wolverine.dll</HintPath>
</Reference>
</ItemGroup>
</Project>