37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using FinancialApi.Application.Commands;
|
|
using FinancialApi.Application.Handlers;
|
|
using FinancialApi.Application.Models;
|
|
using FinancialApi.Domain.Entities;
|
|
using FluentAssertions;
|
|
using FluentAssertions.Execution;
|
|
using Microsoft.Extensions.Time.Testing;
|
|
|
|
namespace FinancialApi.Application.UnitTests;
|
|
|
|
public class ApplyTransferHandlerTests
|
|
{
|
|
public class ApplyFeeHandlerTests
|
|
{
|
|
[Fact]
|
|
public void GivenValidAccounts_BasicFee_ShouldValidateEverything()
|
|
{
|
|
// Arrange
|
|
var fakeTimeProvider = new FakeTimeProvider();
|
|
|
|
var command = new TransferFundsCommand(1, 2, 100);
|
|
var sourceAccount = new Account(1, 100, AccountType.Liability);
|
|
var destAccount = new Account(1, 100, AccountType.Liability);
|
|
var transferContext = new TransferContext(sourceAccount, destAccount, fakeTimeProvider.GetUtcNow());
|
|
|
|
// Act
|
|
var intents = TransferFundsHandler.Handle(command, transferContext);
|
|
|
|
// Assert
|
|
using var _ = new AssertionScope();
|
|
intents.SourceWrite.Entity.Balance.Should()
|
|
.Be(0);
|
|
intents.DestWrite.Entity.Balance.Should()
|
|
.Be(200);
|
|
}
|
|
}
|
|
} |