Added first unit test.
This commit is contained in:
+30
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user