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,146 @@
[*]
charset = utf-8-bom
end_of_line = crlf
trim_trailing_whitespace = false
insert_final_newline = false
indent_style = space
indent_size = 4
# Microsoft .NET properties
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
dotnet_naming_rule.interfaces_rule.import_to_resharper = True
dotnet_naming_rule.interfaces_rule.resharper_description = Interfaces
dotnet_naming_rule.interfaces_rule.resharper_guid = a7a3339e-4e89-4319-9735-a9dc4cb74cc7
dotnet_naming_rule.interfaces_rule.severity = warning
dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style
dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols
dotnet_naming_rule.unity_serialized_field_rule.import_to_resharper = True
dotnet_naming_rule.unity_serialized_field_rule.resharper_description = Unity serialized field
dotnet_naming_rule.unity_serialized_field_rule.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
dotnet_naming_rule.unity_serialized_field_rule.severity = warning
dotnet_naming_rule.unity_serialized_field_rule.style = lower_camel_case_style
dotnet_naming_rule.unity_serialized_field_rule.symbols = unity_serialized_field_symbols
dotnet_naming_rule.unity_serialized_field_rule_1.import_to_resharper = True
dotnet_naming_rule.unity_serialized_field_rule_1.resharper_description = Unity serialized field
dotnet_naming_rule.unity_serialized_field_rule_1.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
dotnet_naming_rule.unity_serialized_field_rule_1.severity = warning
dotnet_naming_rule.unity_serialized_field_rule_1.style = lower_camel_case_style
dotnet_naming_rule.unity_serialized_field_rule_1.symbols = unity_serialized_field_symbols_1
dotnet_naming_rule.unity_serialized_field_rule_2.import_to_resharper = True
dotnet_naming_rule.unity_serialized_field_rule_2.resharper_description = Unity serialized field
dotnet_naming_rule.unity_serialized_field_rule_2.resharper_guid = 5f0fdb63-c892-4d2c-9324-15c80b22a7ef
dotnet_naming_rule.unity_serialized_field_rule_2.severity = warning
dotnet_naming_rule.unity_serialized_field_rule_2.style = lower_camel_case_style
dotnet_naming_rule.unity_serialized_field_rule_2.symbols = unity_serialized_field_symbols_2
dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case
dotnet_naming_style.i_upper_camel_case_style.required_prefix = I
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = *
dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface
dotnet_naming_symbols.interfaces_symbols.resharper_applicable_kinds = interface
dotnet_naming_symbols.interfaces_symbols.resharper_required_modifiers = any
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance
dotnet_naming_symbols.unity_serialized_field_symbols_2.applicable_accessibilities = *
dotnet_naming_symbols.unity_serialized_field_symbols_2.applicable_kinds =
dotnet_naming_symbols.unity_serialized_field_symbols_2.resharper_applicable_kinds = unity_serialised_field
dotnet_naming_symbols.unity_serialized_field_symbols_2.resharper_required_modifiers = instance
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
# ReSharper properties
resharper_align_linq_query = true
resharper_autodetect_indent_settings = true
resharper_braces_for_for = required
resharper_braces_for_foreach = required
resharper_braces_for_ifelse = required
resharper_braces_for_while = required
resharper_cpp_insert_final_newline = true
resharper_csharp_empty_block_style = together_same_line
resharper_csharp_int_align_comments = true
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_after_invocation_lpar = true
resharper_csharp_wrap_arguments_style = chop_if_long
resharper_csharp_wrap_before_declaration_rpar = true
resharper_csharp_wrap_before_invocation_rpar = true
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_formatter_off_tag = @formatter:off
resharper_formatter_on_tag = @formatter:on
resharper_formatter_tags_enabled = true
resharper_keep_existing_expr_member_arrangement = false
resharper_keep_existing_initializer_arrangement = false
resharper_keep_existing_linebreaks = false
resharper_place_field_attribute_on_same_line = if_owner_is_single_line
resharper_place_method_attribute_on_same_line = if_owner_is_single_line
resharper_show_autodetect_configure_formatting_tip = false
resharper_use_indent_from_vs = false
resharper_wrap_before_primary_constructor_declaration_rpar = true
resharper_wrap_chained_method_calls = chop_always
# ReSharper inspection severities
resharper_arrange_redundant_parentheses_highlighting = hint
resharper_arrange_this_qualifier_highlighting = hint
resharper_arrange_type_member_modifiers_highlighting = hint
resharper_arrange_type_modifiers_highlighting = hint
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
resharper_built_in_type_reference_style_highlighting = hint
resharper_enforce_do_while_statement_braces_highlighting = warning
resharper_enforce_fixed_statement_braces_highlighting = warning
resharper_enforce_foreach_statement_braces_highlighting = warning
resharper_enforce_for_statement_braces_highlighting = warning
resharper_enforce_if_statement_braces_highlighting = warning
resharper_enforce_lock_statement_braces_highlighting = warning
resharper_enforce_using_statement_braces_highlighting = warning
resharper_enforce_while_statement_braces_highlighting = warning
resharper_mvc_action_not_resolved_highlighting = warning
resharper_mvc_area_not_resolved_highlighting = warning
resharper_mvc_controller_not_resolved_highlighting = warning
resharper_mvc_masterpage_not_resolved_highlighting = warning
resharper_mvc_partial_view_not_resolved_highlighting = warning
resharper_mvc_template_not_resolved_highlighting = warning
resharper_mvc_view_component_not_resolved_highlighting = warning
resharper_mvc_view_component_view_not_resolved_highlighting = warning
resharper_mvc_view_not_resolved_highlighting = warning
resharper_razor_assembly_not_resolved_highlighting = warning
resharper_redundant_base_qualifier_highlighting = warning
resharper_suggest_var_or_type_built_in_types_highlighting = hint
resharper_suggest_var_or_type_elsewhere_highlighting = hint
resharper_suggest_var_or_type_simple_types_highlighting = hint
resharper_web_config_module_not_resolved_highlighting = warning
resharper_web_config_type_not_resolved_highlighting = warning
resharper_web_config_wrong_module_highlighting = warning
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2
[{tsconfig.app.json,tsconfig.base.json,tsconfig.e2e.json,tsconfig.editor.json,tsconfig.json,tsconfig.lib.json,tsconfig.spec.json,tsconfig.test.json}]
indent_style = space
indent_size = 2
[{*.har,*.jsb2,*.jsb3,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,.ws-context,jest.config}]
indent_style = space
indent_size = 2
[*.{appxmanifest,asax,ascx,aspx,axaml,blockshader,c,c++,c++m,cc,ccm,cginc,compute,cp,cpp,cppm,cs,cshtml,cu,cuh,cxx,cxxm,dtd,fs,fsi,fsscript,fsx,fx,fxh,h,h++,hh,hlsl,hlsli,hlslinc,hp,hpp,hxx,icc,inc,inl,ino,ipp,ixx,master,ml,mli,mpp,mq4,mq5,mqh,mxx,nuspec,paml,pssl,pssli,razor,resw,resx,shader,shaderFoundry,skin,tcc,tpp,urtshader,usf,ush,uxml,vb,xaml,xamlx,xoml,xsd}]
indent_style = space
indent_size = 4
tab_width = 4
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
@@ -0,0 +1,15 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/.idea.a-frame-architecture.iml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.github.l34130.mise.toolwindow.MiseToolWindowState">
<option name="envInitialized" value="true" />
<option name="envOverride" value="build" />
</component>
</project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
@@ -0,0 +1,129 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Handlers;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Exceptions;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.Extensions.Time.Testing;
namespace FinancialApi.Application.UnitTests;
public class ApplyFeeHandlerTests
{
public class SpendAccount
{
[Theory]
[InlineData(100.0, 20.0, 80.0)]
[InlineData(199.78, 10.0, 189.78)]
[InlineData(200000, 0.09, 199999.91)]
[InlineData(1000, 1000, 0)]
public void GivenStartingBalanceGreaterThanFee_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new ApplyFeeCommand(1, feeAmount);
var account = new Account(1, startingBalance, AccountType.Spend);
var revenueAccount = new Account(99999, 0, AccountType.Revenue);
var feeContext = new FeeContext(account, revenueAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) = ApplyFeeHandler.Handle(command, feeContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
}
[Theory]
[InlineData(100.0, 110.0)]
[InlineData(199.78, 200.0)]
[InlineData(200000, 200000.01)]
[InlineData(1000, 1999999)]
public void GivenStartingBalanceLessThanFee_ApplyFee_ShouldFail(decimal startingBalance, decimal feeAmount)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new ApplyFeeCommand(1, feeAmount);
var account = new Account(1, startingBalance, AccountType.Spend);
var revenueAccount = new Account(99999, 0, AccountType.Revenue);
var feeContext = new FeeContext(account, revenueAccount, timeProvider.GetUtcNow());
// Act
var act = () => ApplyFeeHandler.Handle(command, feeContext);
// Assert
using var _ = new AssertionScope();
act.Should()
.Throw<InsufficientFundsException>();
}
}
public class BorrowAccount
{
[Theory]
[InlineData(100.0, 20.0, 80.0)]
[InlineData(199.78, 10.0, 189.78)]
[InlineData(200000, 0.09, 199999.91)]
[InlineData(1000, 1000, 0)]
public void GivenStartingBalanceGreaterThanFee_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new ApplyFeeCommand(1, feeAmount);
var account = new Account(1, startingBalance, AccountType.Borrow);
var revenueAccount = new Account(99999, 0, AccountType.Revenue);
var feeContext = new FeeContext(account, revenueAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) = ApplyFeeHandler.Handle(command, feeContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
}
[Theory]
[InlineData(100.0, 110.0, -10.0)]
[InlineData(199.78, 200.0, -0.22)]
[InlineData(200000, 200000.01, -0.01)]
[InlineData(1000, 1999999, -1998999)]
public void GivenStartingBalanceLessThanFee_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new ApplyFeeCommand(1, feeAmount);
var account = new Account(1, startingBalance, AccountType.Borrow);
var revenueAccount = new Account(99999, 0, AccountType.Revenue);
var feeContext = new FeeContext(account, revenueAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) = ApplyFeeHandler.Handle(command, feeContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
revenueWrite.Entity.Balance.Should()
.Be(feeAmount);
journalWrite.Should()
.NotBeNull();
@event.Should()
.NotBeNull();
}
}
}
@@ -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>
@@ -0,0 +1,67 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Handlers;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Events;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.Extensions.Time.Testing;
using Wolverine.Persistence;
namespace FinancialApi.Application.UnitTests;
public class ReverseJournalHandlerTests
{
[Fact]
public void GivenValidJournalEntry_Reversal_ShouldResetAccountBalances()
{
// Arrange
var timeProvider = new FakeTimeProvider();
var expectedSourceAccountBalance = 100.0m;
var expectedDestAccountBalance = 100.0m;
var (initialSourceAccountWrite, initialDestAccountWrite, initialJournalWrite, initialEvent) =
CreateInitialTransferTransaction(
expectedSourceAccountBalance,
expectedDestAccountBalance,
10,
timeProvider
);
var command = new ReverseJournalCommand(initialJournalWrite.Entity.Id, "Invalid Transaction");
var context = new JournalReversalContext(
initialJournalWrite.Entity,
[initialSourceAccountWrite.Entity, initialDestAccountWrite.Entity],
timeProvider.GetUtcNow()
);
// Act
var (journalWrite, accountWrites, @event) = ReverseJournalHandler.Handle(command, context);
// Assert
using var _ = new AssertionScope();
accountWrites[0]
.Entity.Balance.Should()
.Be(expectedSourceAccountBalance);
accountWrites[1]
.Entity.Balance.Should()
.Be(expectedDestAccountBalance);
journalWrite.Entity.Lines.Should()
.HaveCount(initialJournalWrite.Entity.Lines.Count);
}
private (IStorageAction<Account> SourceWrite, IStorageAction<Account> DestWrite, IStorageAction<BalancedJournalEntry>
JournalWrite, FundsTransferredEvent Event) CreateInitialTransferTransaction(
decimal sourceStartingBalance,
decimal destStartingBalance,
decimal transferAmount,
TimeProvider timeProvider
)
{
var command = new TransferFundsCommand(1, 2, transferAmount);
var sourceAccount = new Account(1, sourceStartingBalance, AccountType.Spend);
var destAccount = new Account(2, destStartingBalance, AccountType.Spend);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
return TransferFundsHandler.Handle(command, transferContext);
}
}
@@ -0,0 +1,154 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Handlers;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Exceptions;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.Extensions.Time.Testing;
namespace FinancialApi.Application.UnitTests;
public class TransferFundsHandlerTests
{
public class LiabilityAccount
{
[Theory]
[InlineData(100.0, 20.0, 80.0)]
[InlineData(199.78, 10.0, 189.78)]
[InlineData(200000, 0.09, 199999.91)]
[InlineData(1000, 1000, 0)]
public void GivenStartingBalanceGreaterThanTransfer_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new TransferFundsCommand(1, 2, feeAmount);
var sourceAccount = new Account(1, startingBalance, AccountType.Spend);
var destAccount = new Account(2, 0, AccountType.Spend);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) =
TransferFundsHandler.Handle(command, transferContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
}
[Theory]
[InlineData(100.0, 110.0)]
[InlineData(199.78, 200.0)]
[InlineData(200000, 200000.01)]
[InlineData(1000, 1999999)]
public void GivenStartingBalanceLessThanTransfer_ApplyFee_ShouldFail(decimal startingBalance, decimal feeAmount)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new TransferFundsCommand(1, 2, feeAmount);
var sourceAccount = new Account(1, startingBalance, AccountType.Spend);
var destAccount = new Account(2, 0, AccountType.Spend);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
var act = () => TransferFundsHandler.Handle(command, transferContext);
// Assert
using var _ = new AssertionScope();
act.Should()
.Throw<InsufficientFundsException>();
}
}
public class CreditAccount
{
[Theory]
[InlineData(100.0, 20.0, 80.0)]
[InlineData(199.78, 10.0, 189.78)]
[InlineData(200000, 0.09, 199999.91)]
[InlineData(1000, 1000, 0)]
public void GivenStartingBalanceGreaterThanFee_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new TransferFundsCommand(1, 2, feeAmount);
var sourceAccount = new Account(1, startingBalance, AccountType.Borrow);
var destAccount = new Account(2, 0, AccountType.Borrow);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) =
TransferFundsHandler.Handle(command, transferContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
}
[Theory]
[InlineData(100.0, 110.0, -10.0)]
[InlineData(199.78, 200.0, -0.22)]
[InlineData(200000, 200000.01, -0.01)]
[InlineData(1000, 1999999, -1998999)]
public void GivenStartingBalanceLessThanFee_ApplyFee_ShouldSucceed(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new TransferFundsCommand(1, 2, feeAmount);
var sourceAccount = new Account(1, startingBalance, AccountType.Borrow);
var destAccount = new Account(2, 0, AccountType.Borrow);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
var act = () => TransferFundsHandler.Handle(command, transferContext);
// Assert
using var _ = new AssertionScope();
act.Should()
.NotThrow();
}
[Theory]
[InlineData(100.0, 110.0, -10.0)]
[InlineData(199.78, 200.0, -0.22)]
[InlineData(200000, 200000.01, -0.01)]
[InlineData(1000, 1999999, -1998999)]
public void GivenStartingBalanceLessThanFee_ApplyFee_ShouldBeExpectedBalance(
decimal startingBalance,
decimal feeAmount,
decimal expectedBalance
)
{
// Arrange
var timeProvider = new FakeTimeProvider();
var command = new TransferFundsCommand(1, 2, feeAmount);
var sourceAccount = new Account(1, startingBalance, AccountType.Borrow);
var destAccount = new Account(2, 0, AccountType.Borrow);
var transferContext = new TransferContext(sourceAccount, destAccount, timeProvider.GetUtcNow());
// Act
var (customerWrite, revenueWrite, journalWrite, @event) =
TransferFundsHandler.Handle(command, transferContext);
// Assert
using var _ = new AssertionScope();
customerWrite.Entity.Balance.Should()
.Be(expectedBalance);
}
}
}
@@ -0,0 +1,3 @@
namespace FinancialApi.Application.Commands;
public record ApplyFeeCommand(int AccountId, decimal Amount);
@@ -0,0 +1,3 @@
namespace FinancialApi.Application.Commands;
public record ReverseJournalCommand(Guid OriginalJournalId, string Reason);
@@ -0,0 +1,3 @@
namespace FinancialApi.Application.Commands;
public record TransferFundsCommand(int SourceAccountId, int DestinationAccountId, decimal Amount);
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\FinancialApi.Domain\FinancialApi.Domain.csproj"/>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\10.0.9\lib\net10.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Wolverine">
<HintPath>..\..\..\..\..\..\.nuget\packages\wolverinefx\6.18.0\lib\net10.0\Wolverine.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,51 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Interfaces;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Aggregates;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Events;
using Wolverine.Persistence;
namespace FinancialApi.Application.Handlers;
public static class ApplyFeeHandler
{
public static async Task<FeeContext> LoadAsync(ApplyFeeCommand cmd, IAccountQuery query, TimeProvider timeProvider)
{
var source = await query.FindByIdAsync(cmd.AccountId);
var dest = await query.FindByIdAsync(99999);
if (source == null || dest == null)
{
throw new InvalidOperationException("Cannot process transfer. Account(s) not found.");
}
return new FeeContext(source, dest, timeProvider.GetUtcNow());
}
public static ( IStorageAction<Account> CustomerWrite, IStorageAction<Account> RevenueWrite,
IStorageAction<BalancedJournalEntry> JournalWrite, FeeAppliedEvent Event ) Handle(
ApplyFeeCommand cmd,
FeeContext context
)
{
var updatedSource = context.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
var updatedRevenue = context.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
var lines = new List<JournalLine>
{
new(updatedSource.Id, cmd.Amount, EntryType.Debit), new(updatedRevenue.Id, cmd.Amount, EntryType.Credit)
};
var journalEntry = BalancedJournal.Create(
Guid.NewGuid(),
$"Service Fee Applied: {cmd.Amount} to Account {cmd.AccountId}",
context.TimeStamp,
lines
);
var @event = new FeeAppliedEvent(cmd.AccountId, cmd.Amount);
return (Storage.Update(updatedSource), Storage.Update(updatedRevenue), Storage.Insert(journalEntry.Entry),
@event);
}
}
@@ -0,0 +1,30 @@
using FinancialApi.Domain.Events;
using Microsoft.Extensions.Logging;
namespace FinancialApi.Application.Handlers;
public static class FinancialEventHandler
{
public static void Handle(FeeAppliedEvent @event, IEventTracker store, ILogger logger)
{
var message = $"FeeApplied: ${@event.Amount} moved from Account {@event.AccountId} to Account 99999.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
store.Add(message);
}
public static void Handle(FundsTransferredEvent @event, IEventTracker store, ILogger logger)
{
var message =
$"FundsTransferred: ${@event.Amount} moved from Account {@event.SourceAccountId} to Account {@event.DestinationAccountId}.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
store.Add(message);
}
public static void Handle(JournalReversedEvent @event, IEventTracker store, ILogger logger)
{
var message =
$"JournalReversed: Original Entry {@event.OriginalJournalId} was reversed by Entry {@event.ReversalJournalId}.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
store.Add(message);
}
}
@@ -0,0 +1,59 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Interfaces;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Aggregates;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Events;
using Wolverine.Persistence;
namespace FinancialApi.Application.Handlers;
public static class ReverseJournalHandler
{
public static async Task<JournalReversalContext?> LoadAsync(
ReverseJournalCommand cmd,
IReversalQuery query,
TimeProvider timeProvider
)
{
var (journalEnty, accounts) = await query.GetReversalDataAsync(cmd.OriginalJournalId);
if (journalEnty == null)
{
throw new InvalidOperationException("Journal not found");
}
if (accounts == null)
{
throw new InvalidOperationException("Journal accounts not found");
}
return new JournalReversalContext(journalEnty, accounts, timeProvider.GetUtcNow()) ??
throw new InvalidOperationException($"Journal Entry {cmd.OriginalJournalId} does not exist");
}
public static (IStorageAction<BalancedJournalEntry> JournalWrite, UnitOfWork<Account> AccountWrites, JournalReversedEvent
Event) Handle(ReverseJournalCommand cmd, JournalReversalContext context)
{
var reversalJournal = BalancedJournal.CreateReversal(
context.OriginalBalancedJournalEntry,
$"Reversal: {cmd.Reason}",
context.TimeStamp
);
var accountState = context.AffectedAccounts.ToDictionary(a => a.Id);
reversalJournal.Entry.Lines.ForEach(l =>
{
var currentAccount = accountState[l.AccountId];
accountState[l.AccountId] = currentAccount.ApplyPosting(l.Amount, l.Type);
}
);
var accountUow = new UnitOfWork<Account>();
foreach (var account in accountState.Values)
{
accountUow.Update(account);
}
return (Storage.Insert(reversalJournal.Entry), accountUow,
new JournalReversedEvent(cmd.OriginalJournalId, reversalJournal.Entry.Id));
}
}
@@ -0,0 +1,53 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Interfaces;
using FinancialApi.Application.Models;
using FinancialApi.Domain.Aggregates;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Events;
using Wolverine.Persistence;
namespace FinancialApi.Application.Handlers;
public static class TransferFundsHandler
{
public static async Task<TransferContext?> LoadAsync(
TransferFundsCommand cmd,
IAccountQuery query,
TimeProvider timeProvider
)
{
var source = await query.FindByIdAsync(cmd.SourceAccountId);
var dest = await query.FindByIdAsync(cmd.DestinationAccountId);
if (source == null || dest == null)
{
return null;
}
return new TransferContext(source, dest, timeProvider.GetUtcNow());
}
public static (IStorageAction<Account> SourceWrite, IStorageAction<Account> DestWrite, IStorageAction<BalancedJournalEntry>
JournalWrite, FundsTransferredEvent Event) Handle(TransferFundsCommand cmd, TransferContext context)
{
var updatedSource = context.Source.ApplyPosting(cmd.Amount, EntryType.Debit);
var updatedDest = context.Destination.ApplyPosting(cmd.Amount, EntryType.Credit);
var lines = new List<JournalLine>
{
new(context.Source.Id, cmd.Amount, EntryType.Debit),
new(context.Destination.Id, cmd.Amount, EntryType.Credit)
};
var journalEntry = BalancedJournal.Create(
Guid.NewGuid(),
$"Transfer: {cmd.Amount} from {cmd.SourceAccountId} to {cmd.DestinationAccountId}",
context.TimeStamp,
lines
);
var @event = new FundsTransferredEvent(cmd.SourceAccountId, cmd.DestinationAccountId, cmd.Amount);
return (Storage.Update(updatedSource), Storage.Update(updatedDest), Storage.Insert(journalEntry.Entry), @event);
}
}
@@ -0,0 +1,8 @@
using FinancialApi.Domain.Entities;
namespace FinancialApi.Application.Interfaces;
public interface IAccountQuery
{
Task<Account?> FindByIdAsync(int id);
}
@@ -0,0 +1,8 @@
using FinancialApi.Domain.Entities;
namespace FinancialApi.Application.Interfaces;
public interface IReversalQuery
{
Task<(BalancedJournalEntry?, List<Account>?)> GetReversalDataAsync(Guid journalEntryId);
}
@@ -0,0 +1,5 @@
using FinancialApi.Domain.Entities;
namespace FinancialApi.Application.Models;
public record FeeContext(Account Source, Account Destination, DateTimeOffset TimeStamp);
@@ -0,0 +1,9 @@
using FinancialApi.Domain.Entities;
namespace FinancialApi.Application.Models;
public record JournalReversalContext(
BalancedJournalEntry OriginalBalancedJournalEntry,
IReadOnlyList<Account> AffectedAccounts,
DateTimeOffset TimeStamp
);
@@ -0,0 +1,5 @@
using FinancialApi.Domain.Entities;
namespace FinancialApi.Application.Models;
public record TransferContext(Account Source, Account Destination, DateTimeOffset TimeStamp);
@@ -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>
@@ -0,0 +1,46 @@
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Exceptions;
namespace FinancialApi.Domain.Aggregates;
public record BalancedJournal
{
public BalancedJournalEntry Entry { get; }
private BalancedJournal(BalancedJournalEntry entry)
{
Entry = entry;
}
public static BalancedJournal Create(Guid id, string description, DateTimeOffset createdAt, List<JournalLine> lines)
{
if (lines.Count(l => l.Type == EntryType.Debit) == 0)
{
throw new GaapViolationException($"GAAP Violation: A journal entry needs at least one debit line.");
}
if (lines.Count(l => l.Type == EntryType.Credit) == 0)
{
throw new GaapViolationException($"A journal entry needs at least one credit line.");
}
var debits = lines.Where(l => l.Type == EntryType.Debit)
.Sum(l => l.Amount);
var credits = lines.Where(l => l.Type == EntryType.Credit)
.Sum(l => l.Amount);
return debits != credits
? throw new GaapViolationException($"Total Debits ({debits}) must equal Total Credits ({credits})!")
: new BalancedJournal(new BalancedJournalEntry(id, description, createdAt, lines));
}
public static BalancedJournal CreateReversal(BalancedJournalEntry original, string reason, DateTimeOffset now)
{
var reversedLines = original.Lines.Select(l =>
l with { Type = l.Type == EntryType.Debit ? EntryType.Credit : EntryType.Debit }
)
.ToList();
return Create(Guid.NewGuid(), reason, now, reversedLines);
}
}
@@ -0,0 +1,53 @@
using FinancialApi.Domain.Exceptions;
namespace FinancialApi.Domain.Entities;
public enum AccountType
{
Spend,
Borrow,
Revenue
}
public record Account
{
public Account(int Id, decimal Balance, AccountType Type)
{
this.Id = Id;
this.Balance = Balance;
this.Type = Type;
if (Balance < 0 && Type is AccountType.Spend or AccountType.Revenue)
{
throw new InvalidStartingBalanceException("Insufficient funds.");
}
}
public Account ApplyPosting(decimal amount, EntryType entryType)
{
if (amount <= 0)
{
throw new ArgumentException("Amount must be positive.");
}
var newBalance = entryType == EntryType.Credit ? Balance + amount : Balance - amount;
if (newBalance < 0 && Type is AccountType.Spend or AccountType.Revenue)
{
throw new InsufficientFundsException("Insufficient funds.");
}
return this with { Balance = newBalance };
}
public int Id { get; init; }
public decimal Balance { get; init; }
public AccountType Type { get; init; }
public void Deconstruct(out int Id, out decimal Balance, out AccountType Type)
{
Id = this.Id;
Balance = this.Balance;
Type = this.Type;
}
}
@@ -0,0 +1,19 @@
namespace FinancialApi.Domain.Entities;
public record BalancedJournalEntry
{
public Guid Id { get; init; }
public string Description { get; init; } = null!;
public DateTimeOffset CreatedAt { get; init; }
public List<JournalLine> Lines { get; init; } = [];
internal BalancedJournalEntry() { }
internal BalancedJournalEntry(Guid id, string description, DateTimeOffset createdAt, List<JournalLine> lines)
{
Lines = lines;
Id = id;
Description = description;
CreatedAt = createdAt;
}
}
@@ -0,0 +1,7 @@
namespace FinancialApi.Domain.Entities;
public enum EntryType
{
Debit,
Credit
}
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Entities;
public record JournalLine(int AccountId, decimal Amount, EntryType Type);
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Events;
public record FeeAppliedEvent(int AccountId, decimal Amount);
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Events;
public record FundsTransferredEvent(int SourceAccountId, int DestinationAccountId, decimal Amount);
@@ -0,0 +1,6 @@
namespace FinancialApi.Domain.Events;
public interface IEventTracker
{
void Add(string eventMessage);
}
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Events;
public record JournalReversedEvent(Guid OriginalJournalId, Guid ReversalJournalId);
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Exceptions;
public class GaapViolationException(string message) : Exception(message);
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Exceptions;
public class InsufficientFundsException(string message) : GaapViolationException(message);
@@ -0,0 +1,3 @@
namespace FinancialApi.Domain.Exceptions;
public class InvalidStartingBalanceException(string message) : GaapViolationException(message);
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,221 @@
namespace FinancialApi.Domain;
public interface IFinancialError
{
int ErrorCode { get; }
string Message { get; }
Exception? Exception { get; }
}
public sealed class FinancialError : IFinancialError
{
public FinancialError(int errorCode, string message, Exception? exception = null)
{
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(errorCode);
ErrorCode = errorCode;
Message = message ?? throw new ArgumentNullException(nameof(message));
Exception = exception;
}
public int ErrorCode { get; }
public string Message { get; }
public Exception? Exception { get; }
public override string ToString() => $"Error: {ErrorCode} - {Message}{(Exception == null ? "" : $"\n{Exception}")}";
}
public sealed class FinancialResult<T>
{
private readonly T? _resultValue;
private readonly FinancialError? _resultError;
public FinancialResult(T resultValue)
{
IsError = false;
_resultValue = resultValue;
_resultError = null;
}
public FinancialResult(FinancialError resultError)
{
IsError = true;
_resultValue = default;
_resultError = resultError;
}
public bool IsError { get; }
/// <summary>
/// Error indicator
/// </summary>
public bool IsSuccess => !IsError;
/// <summary>
/// Result Values
/// </summary>
public T? Value => _resultValue;
public FinancialError? Error => _resultError;
public static implicit operator FinancialResult<T>(T resultValue) => new(resultValue);
public static implicit operator FinancialResult<T>(FinancialError resultError) => new(resultError);
public static FinancialResult<T> Success(T successValue)
{
return new FinancialResult<T>(successValue);
}
public static FinancialResult<T> Failure(FinancialError failureValue)
{
return new FinancialResult<T>(failureValue);
}
public TResult Match<TResult>(
Func<T, TResult> success,
Func<FinancialError, TResult> failure,
Func<TResult> nullValue
)
{
return IsError switch
{
false when _resultValue == null => nullValue(),
true => failure(_resultError!),
_ => success(_resultValue)
};
}
public TResult Match<TResult>(Func<T, TResult> success, Func<FinancialError, TResult> failure)
{
return IsError switch
{
true => failure(_resultError!),
_ => success(_resultValue!)
};
}
public TResult? Match<TResult>(Func<T, TResult> success)
{
return IsError switch
{
true => default,
_ => success(_resultValue!)
};
}
public void Match(Action<T> success, Action<FinancialError> failure, Action nullValue)
{
switch (IsError)
{
case false when _resultValue == null:
nullValue.Invoke();
return;
case true:
failure.Invoke(_resultError!);
return;
default:
success(_resultValue);
break;
}
}
public void Match(Action<T> success, Action<FinancialError> failure)
{
switch (IsError)
{
case true:
failure.Invoke(_resultError!);
return;
default:
success(_resultValue!);
break;
}
}
public void Match(Action<T> success)
{
if (IsError)
{
return;
}
success(_resultValue!);
}
public async Task<TResult> MatchAsync<TResult>(
Func<T, Task<TResult>> success,
Func<FinancialError, Task<TResult>> failure,
Func<Task<TResult>> nullValue
)
{
return IsError switch
{
false when _resultValue == null => await nullValue(),
true => await failure(_resultError!),
_ => await success(_resultValue)
};
}
public async Task<TResult> MatchAsync<TResult>(
Func<T, Task<TResult>> success,
Func<FinancialError, Task<TResult>> failure
)
{
return IsError switch
{
true => await failure(_resultError!),
_ => await success(_resultValue!)
};
}
public async Task<TResult?> MatchAsync<TResult>(Func<T, Task<TResult>> success)
{
return IsError switch
{
true => default,
_ => await success(_resultValue!)
};
}
public async Task MatchAsync(Func<T, Task> success, Func<FinancialError, Task> failure, Func<Task> nullValue)
{
switch (IsError)
{
case false when _resultValue == null:
await nullValue.Invoke();
return;
case true:
await failure.Invoke(_resultError!);
return;
default:
await success(_resultValue!);
break;
}
}
public async Task MatchAsync(Func<T, Task> success, Func<FinancialError, Task> failure)
{
switch (IsError)
{
case true:
await failure.Invoke(_resultError!);
return;
default:
await success(_resultValue!);
break;
}
}
public async Task MatchAsync(Func<T, Task> success)
{
if (IsError)
{
return;
}
await success(_resultValue!);
}
}
@@ -0,0 +1,35 @@
using FinancialApi.Application.Commands;
using FinancialApi.Application.Interfaces;
using FinancialApi.Domain.Entities;
using FinancialApi.Domain.Events;
using FluentAssertions;
using Wolverine;
using Wolverine.Tracking;
namespace FinancialApi.Infrastructure.Tests;
internal class FakeAccountQuery : IAccountQuery
{
public Task<Account?> FindByIdAsync(int id) => Task.FromResult(new Account(id, 100.00m, AccountType.Spend))!;
}
public class ApplyFeeIntegrationTests(WolverineTestFixture fixture) : IClassFixture<WolverineTestFixture>
{
[Fact]
public async Task GivenValidCommand_WhenApplyingFee_ShouldPublishFeeAppliedEvent()
{
// Arrange
var command = new ApplyFeeCommand(1, 100);
// Act
var session = await fixture.Host.InvokeMessageAndWaitAsync(command);
// Assert
session.Sent.AllMessages()
.ShouldHaveMessageOfType<FeeAppliedEvent>();
session.Sent.MessagesOf<FeeAppliedEvent>()
.Count()
.Should()
.Be(1);
}
}
@@ -0,0 +1,41 @@
<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.Extensions.Hosting.Abstractions" Version="10.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="NSubstitute" Version="6.0.0" />
<PackageReference Include="WolverineFx" Version="6.24.1" />
<PackageReference Include="WolverineFx.RuntimeCompilation" Version="6.24.1" />
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"/>
</ItemGroup>
<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Hosting">
<HintPath>..\..\..\..\..\..\.nuget\packages\microsoft.extensions.hosting\10.0.0\lib\net10.0\Microsoft.Extensions.Hosting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
<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>
<ItemGroup>
<ProjectReference Include="..\FinancialApi.Application\FinancialApi.Application.csproj" />
<ProjectReference Include="..\FinancialApi.Infrastructure\FinancialApi.Infrastructure.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,34 @@
using FinancialApi.Application.Handlers;
using FinancialApi.Application.Interfaces;
using FinancialApi.Domain.Events;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Time.Testing;
using Wolverine;
namespace FinancialApi.Infrastructure.Tests;
public class WolverineTestFixture : IDisposable
{
public IHost Host { get; }
public WolverineTestFixture()
{
// We build and start the host ONCE here
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddSingleton<IAccountQuery>(_ => new FakeAccountQuery());
services.AddSingleton<TimeProvider>(_ => new FakeTimeProvider());
services.AddSingleton<IEventTracker>(_ => new DemoEventStore());
}
)
.UseWolverine(opts => { opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly); })
.Start();
}
public void Dispose()
{
Host.Dispose();
}
}
@@ -0,0 +1,42 @@
using FinancialApi.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace FinancialApi.Infrastructure;
public class AccountDbContext(DbContextOptions<AccountDbContext> options) : DbContext(options)
{
public DbSet<Account> Accounts => Set<Account>();
public DbSet<BalancedJournalEntry> JournalEntries => Set<BalancedJournalEntry>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Account>()
.HasKey(x => x.Id);
modelBuilder.Entity<Account>()
.HasData(
new Account(1, 10000000.00m, AccountType.Borrow),
new Account(2, 50000000.00m, AccountType.Spend),
new Account(99999, 0.00m, AccountType.Revenue)
);
modelBuilder.Entity<BalancedJournalEntry>(builder =>
{
builder.HasKey(x => x.Id);
builder.OwnsMany(
x => x.Lines,
line =>
{
line.WithOwner()
.HasForeignKey("JournalEntryId");
line.Property<int>("Id")
.ValueGeneratedOnAdd();
line.HasKey("Id");
line.Property(x => x.Type)
.HasConversion<string>();
}
);
}
);
}
}
@@ -0,0 +1,14 @@
using FinancialApi.Application.Interfaces;
using FinancialApi.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace FinancialApi.Infrastructure;
public class AccountQuery(AccountDbContext db) : IAccountQuery
{
public async Task<Account?> FindByIdAsync(int id)
{
return await db.Accounts.AsNoTracking()
.FirstOrDefaultAsync(x => x.Id == id);
}
}
@@ -0,0 +1,13 @@
using FinancialApi.Domain.Events;
namespace FinancialApi.Infrastructure;
public class DemoEventStore : IEventTracker
{
public List<string> CapturedEvents { get; } = new();
public void Add(string eventMessage)
{
CapturedEvents.Add($"[{DateTimeOffset.UtcNow:HH:mm:ss}] {eventMessage}");
}
}
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\FinancialApi.Application\FinancialApi.Application.csproj"/>
<ProjectReference Include="..\FinancialApi.Domain\FinancialApi.Domain.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.9"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.9"/>
<PackageReference Include="WolverineFx" Version="6.18.0"/>
<PackageReference Include="WolverineFx.EntityFrameworkCore" Version="6.18.0"/>
<PackageReference Include="WolverineFx.Sqlite" Version="6.18.0"/>
</ItemGroup>
</Project>
@@ -0,0 +1,50 @@
// <auto-generated />
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260713152041_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Application.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
Balance = 100.00m
},
new
{
Id = 2,
Balance = 500.00m
});
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Balance = table.Column<decimal>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
});
migrationBuilder.InsertData(
table: "Accounts",
columns: new[] { "Id", "Balance" },
values: new object[,]
{
{ 1, 100.00m },
{ 2, 500.00m }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
}
}
}
@@ -0,0 +1,115 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260715093924_AddJournal")]
partial class AddJournal
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Application.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AccountType")
.IsRequired()
.HasColumnType("TEXT");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
AccountType = "Credit",
Balance = 100.00m
},
new
{
Id = 2,
AccountType = "Liability",
Balance = 500.00m
},
new
{
Id = 99999,
AccountType = "Revenue",
Balance = 0.00m
});
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
{
b.OwnsMany("FinancialApi.Application.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,100 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddJournal : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "AccountType",
table: "Accounts",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "JournalEntries",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JournalEntries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "JournalLine",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
AccountId = table.Column<int>(type: "INTEGER", nullable: false),
Amount = table.Column<decimal>(type: "TEXT", nullable: false),
Type = table.Column<string>(type: "TEXT", nullable: false),
JournalEntryId = table.Column<Guid>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JournalLine", x => x.Id);
table.ForeignKey(
name: "FK_JournalLine_JournalEntries_JournalEntryId",
column: x => x.JournalEntryId,
principalTable: "JournalEntries",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "AccountType",
value: "Credit");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "AccountType",
value: "Liability");
migrationBuilder.InsertData(
table: "Accounts",
columns: new[] { "Id", "AccountType", "Balance" },
values: new object[] { 99999, "Revenue", 0.00m });
migrationBuilder.CreateIndex(
name: "IX_JournalLine_JournalEntryId",
table: "JournalLine",
column: "JournalEntryId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JournalLine");
migrationBuilder.DropTable(
name: "JournalEntries");
migrationBuilder.DeleteData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999);
migrationBuilder.DropColumn(
name: "AccountType",
table: "Accounts");
}
}
}
@@ -0,0 +1,115 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260715100428_UpdateAccountBalances")]
partial class UpdateAccountBalances
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Application.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AccountType")
.IsRequired()
.HasColumnType("TEXT");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
AccountType = "Credit",
Balance = 10000000.00m
},
new
{
Id = 2,
AccountType = "Liability",
Balance = 50000000.00m
},
new
{
Id = 99999,
AccountType = "Revenue",
Balance = 0.00m
});
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Application.JournalEntry", b =>
{
b.OwnsMany("FinancialApi.Application.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdateAccountBalances : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Balance",
value: 10000000.00m);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "Balance",
value: 50000000.00m);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Balance",
value: 100.00m);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "Balance",
value: 500.00m);
}
}
}
@@ -0,0 +1,114 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260729103021_AccountTypes")]
partial class AccountTypes
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Domain.Entities.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
Balance = 10000000.00m,
Type = 2
},
new
{
Id = 2,
Balance = 50000000.00m,
Type = 0
},
new
{
Id = 99999,
Balance = 0.00m,
Type = 3
});
});
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Domain.Entities.JournalEntry", b =>
{
b.OwnsMany("FinancialApi.Domain.Entities.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AccountTypes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AccountType",
table: "Accounts");
migrationBuilder.AddColumn<int>(
name: "Type",
table: "Accounts",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Type",
value: 2);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "Type",
value: 0);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "Type",
value: 3);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Type",
table: "Accounts");
migrationBuilder.AddColumn<string>(
name: "AccountType",
table: "Accounts",
type: "TEXT",
nullable: false,
defaultValue: "");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "AccountType",
value: "Credit");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 2,
column: "AccountType",
value: "Liability");
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "AccountType",
value: "Revenue");
}
}
}
@@ -0,0 +1,114 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
[Migration("20260731073046_UpdateAccountTypes")]
partial class UpdateAccountTypes
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Domain.Entities.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
Balance = 10000000.00m,
Type = 1
},
new
{
Id = 2,
Balance = 50000000.00m,
Type = 0
},
new
{
Id = 99999,
Balance = 0.00m,
Type = 2
});
});
modelBuilder.Entity("FinancialApi.Domain.Entities.BalancedJournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Domain.Entities.BalancedJournalEntry", b =>
{
b.OwnsMany("FinancialApi.Domain.Entities.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class UpdateAccountTypes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Type",
value: 1);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "Type",
value: 2);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 1,
column: "Type",
value: 2);
migrationBuilder.UpdateData(
table: "Accounts",
keyColumn: "Id",
keyValue: 99999,
column: "Type",
value: 3);
}
}
}
@@ -0,0 +1,111 @@
// <auto-generated />
using System;
using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FinancialApi.Infrastructure.Migrations
{
[DbContext(typeof(AccountDbContext))]
partial class AccountDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.9");
modelBuilder.Entity("FinancialApi.Domain.Entities.Account", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<decimal>("Balance")
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Accounts");
b.HasData(
new
{
Id = 1,
Balance = 10000000.00m,
Type = 1
},
new
{
Id = 2,
Balance = 50000000.00m,
Type = 0
},
new
{
Id = 99999,
Balance = 0.00m,
Type = 2
});
});
modelBuilder.Entity("FinancialApi.Domain.Entities.BalancedJournalEntry", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("JournalEntries");
});
modelBuilder.Entity("FinancialApi.Domain.Entities.BalancedJournalEntry", b =>
{
b.OwnsMany("FinancialApi.Domain.Entities.JournalLine", "Lines", b1 =>
{
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("AccountId")
.HasColumnType("INTEGER");
b1.Property<decimal>("Amount")
.HasColumnType("TEXT");
b1.Property<Guid>("JournalEntryId")
.HasColumnType("TEXT");
b1.Property<string>("Type")
.IsRequired()
.HasColumnType("TEXT");
b1.HasKey("Id");
b1.HasIndex("JournalEntryId");
b1.ToTable("JournalLine");
b1.WithOwner()
.HasForeignKey("JournalEntryId");
});
b.Navigation("Lines");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,30 @@
using FinancialApi.Application.Interfaces;
using FinancialApi.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace FinancialApi.Infrastructure;
public class ReversalQuery(AccountDbContext db) : IReversalQuery
{
public async Task<(BalancedJournalEntry?, List<Account>?)> GetReversalDataAsync(Guid journalEntryId)
{
var entry = await db.JournalEntries.Include(x => x.Lines)
.AsNoTracking()
.FirstOrDefaultAsync(x => x.Id == journalEntryId);
if (entry == null)
{
return (null, null);
}
var accountIds = entry.Lines.Select(l => l.AccountId)
.Distinct()
.ToList();
var accounts = await db.Accounts.AsNoTracking()
.Where(a => accountIds.Contains(a.Id))
.ToListAsync();
return (entry, accounts);
}
}
@@ -0,0 +1,135 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
namespace FinancialApi.ServiceDefaults;
// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/aspire/service-defaults
public static class Extensions
{
private const string HealthEndpointPath = "/health";
private const string AlivenessEndpointPath = "/alive";
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();
builder.AddDefaultHealthChecks();
builder.Services.AddServiceDiscovery();
builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();
// Turn on service discovery by default
http.AddServiceDiscovery();
}
);
// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });
return builder;
}
public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
}
);
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
}
)
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation(tracing =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath) &&
!context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
}
);
builder.AddOpenTelemetryExporters();
return builder;
}
private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry()
.UseOtlpExporter();
}
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}
return builder;
}
public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder)
where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
return builder;
}
public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);
// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks(
AlivenessEndpointPath,
new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") }
);
}
return app;
}
}
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.7.0"/>
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="10.7.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.16.0"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.16.0"/>
</ItemGroup>
</Project>
@@ -0,0 +1,33 @@
using FinancialApi.Domain.Exceptions;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
namespace FinancialApi;
public class DomainExceptionHandler : IExceptionHandler
{
public async ValueTask<bool> TryHandleAsync(
HttpContext httpContext,
Exception exception,
CancellationToken cancellationToken
)
{
if (exception is not (InvalidOperationException or ArgumentException or GaapViolationException))
{
return false;
}
var problemDetails = new ProblemDetails
{
Status = StatusCodes.Status400BadRequest,
Title = "Domain Validation Error",
Detail = exception.Message,
Type = "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1"
};
httpContext.Response.StatusCode = problemDetails.Status.Value;
await httpContext.Response.WriteAsJsonAsync(problemDetails, cancellationToken);
return true;
}
}
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.9"/>
<PackageReference Include="Microsoft.OpenApi" Version="2.10.0"/>
<PackageReference Include="WolverineFx" Version="6.18.0"/>
<PackageReference Include="WolverineFx.Http" Version="6.18.0"/>
<PackageReference Include="WolverineFx.RuntimeCompilation" Version="6.18.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FinancialApi.Infrastructure\FinancialApi.Infrastructure.csproj"/>
<ProjectReference Include="..\FinancialApi.ServiceDefaults\FinancialApi.ServiceDefaults.csproj"/>
</ItemGroup>
</Project>
@@ -0,0 +1,38 @@
@FinancialApi_HostAddress = https://localhost:7010
### Apply Fee to an Account
POST {{FinancialApi_HostAddress}}/accounts/apply-fee
Accept: application/json
Content-Type: application/json
{
"accountId": 2,
"amount": 100
}
### Transfer Between Accounts
POST {{FinancialApi_HostAddress}}/accounts/transfer
Content-Type: application/json
{
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 1000.00
}
### Reverse a Journal Entry
POST {{FinancialApi_HostAddress}}/journal/reverse
Content-Type: application/json
{
"originalJournalId": "E7FB25DB-406F-4063-A4B0-DE6BB8292437",
"reason": "Incorrect Account Fee"
}
### Events
GET {{FinancialApi_HostAddress}}/events
Content-Type: application/json
@@ -0,0 +1,103 @@
using FinancialApi;
using FinancialApi.Application.Commands;
using FinancialApi.Application.Handlers;
using FinancialApi.Application.Interfaces;
using FinancialApi.Domain.Events;
using FinancialApi.Infrastructure;
using FinancialApi.ServiceDefaults;
using JasperFx.Resources;
using Microsoft.EntityFrameworkCore;
using Wolverine;
using Wolverine.EntityFrameworkCore;
using Wolverine.Sqlite;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddExceptionHandler<DomainExceptionHandler>();
builder.Services.AddProblemDetails();
var connectionString = "Data Source=demo.db";
builder.Services.AddDbContext<AccountDbContext>(options => options.UseSqlite(connectionString));
builder.Services.AddScoped<IAccountQuery, AccountQuery>();
builder.Services.AddScoped<IReversalQuery, ReversalQuery>();
builder.Services.AddSingleton<IEventTracker, DemoEventStore>();
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
builder.AddServiceDefaults();
builder.Host.UseWolverine(opts =>
{
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
opts.PersistMessagesWithSqlite(connectionString);
opts.UseEntityFrameworkCoreTransactions();
opts.Policies.AutoApplyTransactions();
}
);
builder.Host.UseResourceSetupOnStartup();
var app = builder.Build();
app.UseExceptionHandler();
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<AccountDbContext>();
await db.Database.MigrateAsync();
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
app.MapPost(
"/accounts/apply-fee",
async (ApplyFeeCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
app.MapPost(
"/accounts/transfer",
async (TransferFundsCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
app.MapPost(
"/journal/reverse",
async (ReverseJournalCommand cmd, IMessageBus bus) =>
{
await bus.InvokeAsync(cmd);
return Results.Accepted();
}
);
app.MapGet(
"/events",
(IEventTracker tracker) =>
{
if (tracker is DemoEventStore store)
{
return Results.Ok(store.CapturedEvents);
}
return Results.NotFound();
}
);
app.Run();
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5115",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7010;http://localhost:5115",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
@@ -0,0 +1,58 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.ServiceDefaults", "FinancialApi.ServiceDefaults\FinancialApi.ServiceDefaults.csproj", "{D9767D77-0B2D-4653-9B9C-A0E6A3850EA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi", "FinancialApi\FinancialApi.csproj", "{9EFD8279-869B-485C-BA02-C983E96348A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Application", "FinancialApi.Application\FinancialApi.Application.csproj", "{B7EB1ECE-9F7F-440B-8818-28A127A99915}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Infrastructure", "FinancialApi.Infrastructure\FinancialApi.Infrastructure.csproj", "{6AB36AB5-05BD-41C8-9498-63EBDFAF8114}"
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Domain.Tests", "FinancialApi.Domain.Tests\FinancialApi.Domain.Tests.csproj", "{C15E3FE0-6E3D-4FFC-892E-D469536ADC13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinancialApi.Infrastructure.Tests", "FinancialApi.Infrastructure.Tests\FinancialApi.Infrastructure.Tests.csproj", "{8C1BA932-16F2-42B3-A07C-C589C31044B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D9767D77-0B2D-4653-9B9C-A0E6A3850EA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9767D77-0B2D-4653-9B9C-A0E6A3850EA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9767D77-0B2D-4653-9B9C-A0E6A3850EA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9767D77-0B2D-4653-9B9C-A0E6A3850EA3}.Release|Any CPU.Build.0 = Release|Any CPU
{9EFD8279-869B-485C-BA02-C983E96348A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EFD8279-869B-485C-BA02-C983E96348A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EFD8279-869B-485C-BA02-C983E96348A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EFD8279-869B-485C-BA02-C983E96348A0}.Release|Any CPU.Build.0 = Release|Any CPU
{B7EB1ECE-9F7F-440B-8818-28A127A99915}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7EB1ECE-9F7F-440B-8818-28A127A99915}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7EB1ECE-9F7F-440B-8818-28A127A99915}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7EB1ECE-9F7F-440B-8818-28A127A99915}.Release|Any CPU.Build.0 = Release|Any CPU
{6AB36AB5-05BD-41C8-9498-63EBDFAF8114}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AB36AB5-05BD-41C8-9498-63EBDFAF8114}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AB36AB5-05BD-41C8-9498-63EBDFAF8114}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AB36AB5-05BD-41C8-9498-63EBDFAF8114}.Release|Any CPU.Build.0 = Release|Any CPU
{2DB493D2-1C96-4F7C-9AB6-2846A92860B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{C15E3FE0-6E3D-4FFC-892E-D469536ADC13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C15E3FE0-6E3D-4FFC-892E-D469536ADC13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C15E3FE0-6E3D-4FFC-892E-D469536ADC13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C15E3FE0-6E3D-4FFC-892E-D469536ADC13}.Release|Any CPU.Build.0 = Release|Any CPU
{8C1BA932-16F2-42B3-A07C-C589C31044B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C1BA932-16F2-42B3-A07C-C589C31044B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C1BA932-16F2-42B3-A07C-C589C31044B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C1BA932-16F2-42B3-A07C-C589C31044B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
@@ -0,0 +1,15 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AConfiguredTaskAwaitable_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe929cb9673c947ad9269facdac90006adb3400_003F14_003Fd939fe0a_003FConfiguredTaskAwaitable_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AConstructorBindingFactory_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fda476e261fcf49b394c1074b25b4cdce2b2960_003Fd4_003Fb1aa95c1_003FConstructorBindingFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AConstructorBindingFactory_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fda476e261fcf49b394c1074b25b4cdce2b2960_003Fb3_003F33475782_003FConstructorBindingFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADbContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fda476e261fcf49b394c1074b25b4cdce2b2960_003F37_003F1b1010ed_003FDbContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIWolverineHandler_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc2ddfdf7a216a59ed0f8739e93a88d24d346f54097c7eba6ba93c55690d4_003FIWolverineHandler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ALateBoundTestFramework_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fcffa676d9bfc6c7a1c9d0d25ead15b3b0c9e12e3187bf397eaa52260e5fd91_003FLateBoundTestFramework_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessageContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fb263759e5fefb34bcd589e63aeba791cef6f591ecbc93d1a7e62befa9e8bc6_003FMessageContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARelationalLoggerExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fb797502679b4aa8376708777b4db8d11e31a798d7e6bead76c15bdfa30834892_003FRelationalLoggerExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe929cb9673c947ad9269facdac90006adb3400_003Ff0_003F6b0e8a92_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AWolverineRuntime_002EHostService_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FSourcesCache_003F97bae8f1ffdd86c14edef353d7a85d3d3773b56c68e3a62e8815d1afaacbe797_003FWolverineRuntime_002EHostService_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=ea7499a6_002Ddeba_002D4139_002Dac76_002D505e3f7f2642/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>
</wpf:ResourceDictionary>
+20
View File
@@ -0,0 +1,20 @@
[tools]
dotnet = "10"
[tasks.restore]
description = "Restore the Project"
run = "dotnet restore"
[tasks.build]
depends = ["restore"]
description = "Build the Project"
run = "dotnet build"
[tasks.clean]
run = "fd -I \"bin|obj\" -td -X rm -r && dotnet clean"
[tasks.migrate]
usage = '''
arg "<name>" help="Migration Name"
'''
run = "dotnet ef migrations add \"${usage_name?}\" --startup-project FinancialApi --project FinancialApi.Infrastructure"