Added a-frame-architecture usiung wolverine sample.

This commit is contained in:
2026-08-03 17:08:18 +02:00
parent 1b5bf4f8d4
commit 61fe59cf83
72 changed files with 3012 additions and 0 deletions
@@ -0,0 +1,55 @@
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Exceptions;
using FluentAssertions;
namespace FinancialApi.Domain.Tests;
public class AccountTests
{
[Theory]
[InlineData(AccountType.Borrow)]
public void CreateBorrowAccountType_ShouldAllowNegativeBalance(AccountType accountType)
{
var act = () => new Account(1, -100, accountType);
act()
.Balance.Should()
.BeNegative();
}
[Theory]
[InlineData(AccountType.Revenue)]
[InlineData(AccountType.Spend)]
public void CreateDebitAccountType_ShouldNotAllowNegativeBalance(AccountType accountType)
{
var act = () => new Account(1, -100, accountType);
act.Should()
.Throw<InvalidStartingBalanceException>();
}
[Theory]
[InlineData(AccountType.Borrow)]
public void GivenCreditAccountType_ShouldAllowNegativeBalance(AccountType accountType)
{
var account = new Account(1, 0, accountType);
var updatedAccount = account.ApplyPosting(100, EntryType.Debit);
updatedAccount.Balance.Should()
.BeNegative();
}
[Theory]
[InlineData(AccountType.Revenue)]
[InlineData(AccountType.Spend)]
public void GivenDebitAccountType_ShouldNotAllowNegativeBalance(AccountType accountType)
{
var account = new Account(1, 0, accountType);
var act = () => account.ApplyPosting(100, EntryType.Debit);
act.Should()
.Throw<InsufficientFundsException>();
}
}
@@ -0,0 +1,54 @@
using FinancialApi.Domain.Aggregates;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Exceptions;
using FluentAssertions;
using Microsoft.Extensions.Time.Testing;
namespace FinancialApi.Domain.Tests;
public class BalancedJournalEntryTests
{
[Fact]
public void GivenBalanceJournal_ShouldSucceed()
{
// Arrange
var timeProvider = new FakeTimeProvider();
List<JournalLine> lines = [new(1, 100, EntryType.Debit), new(1, 100, EntryType.Credit)];
// Act
var act = () => BalancedJournal.Create(Guid.NewGuid(), "Transfer", timeProvider.GetUtcNow(), lines);
// Assert
act.Should()
.NotThrow();
}
[Fact]
public void GivenUnbalancedJournal_ShouldFail()
{
// Arrange
var timeProvider = new FakeTimeProvider();
List<JournalLine> lines = [new(1, 10, EntryType.Debit), new(1, 100, EntryType.Credit)];
// Act
var act = () => BalancedJournal.Create(Guid.NewGuid(), "Transfer", timeProvider.GetUtcNow(), lines);
// Assert
act.Should()
.Throw<GaapViolationException>();
}
[Fact]
public void GivenEmptyJournal_ShouldFail()
{
// Arrange
var timeProvider = new FakeTimeProvider();
// Act
var act = () => BalancedJournal.Create(Guid.NewGuid(), "Transfer", timeProvider.GetUtcNow(), []);
// Assert
act.Should()
.Throw<GaapViolationException>();
}
}
@@ -0,0 +1,32 @@
<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="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.Domain\FinancialApi.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.TimeProvider.Testing">
<HintPath>..\..\..\..\..\..\.nuget\packages\microsoft.extensions.timeprovider.testing\10.6.0\lib\net10.0\Microsoft.Extensions.TimeProvider.Testing.dll</HintPath>
</Reference>
</ItemGroup>
</Project>