Unit test improvements.
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
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 TransferFundsHandlerTests
|
||||
{
|
||||
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 (sourceWrite, destWrite, journalWrite, @event) = TransferFundsHandler.Handle(command, transferContext);
|
||||
|
||||
// Assert
|
||||
using var _ = new AssertionScope();
|
||||
sourceWrite.Entity.Balance.Should()
|
||||
.Be(0);
|
||||
destWrite.Entity.Balance.Should()
|
||||
.Be(200);
|
||||
journalWrite.Entity.Lines.Should()
|
||||
.HaveCountGreaterThanOrEqualTo(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user