96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using LCU.API.Collections.RepoApi.Domain.AlertChecker;
|
|
using LCU.API.Collections.RepoApi.Domain.Processing;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
using LCU.Shared.Collections.RepoApiLib.Models.Consumer;
|
|
using Xunit;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.AlertCheckers
|
|
{
|
|
public class TransactionHistoryCheckerTest
|
|
{
|
|
private DummyTransactionChecker _transactionHistoryChecker;
|
|
|
|
[Fact]
|
|
public void Does_Not_Create_Alert_When_Posting_Date_Is_Too_old()
|
|
{
|
|
var transactions = new List<CoreTransaction>()
|
|
{
|
|
new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Now.AddDays(-5),
|
|
transactionTypeCode = "TEST"
|
|
}
|
|
};
|
|
_transactionHistoryChecker = new DummyTransactionChecker();
|
|
var slip = new RepoAccountProcessingSlip()
|
|
{
|
|
TransactionHistory = transactions,
|
|
ExistingRepoAccount = new RepoAccount(),
|
|
UpdatedRepoAccount = new RepoAccount()
|
|
};
|
|
|
|
var result = _transactionHistoryChecker.CheckForAlert(slip);
|
|
|
|
Assert.Null(result);
|
|
}
|
|
|
|
[Fact]
|
|
public void Does_Not_Create_Alert_When_Transaction_Type_Is_Wrong()
|
|
{
|
|
var transactions = new List<CoreTransaction>()
|
|
{
|
|
new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Now.AddDays(-1),
|
|
transactionTypeCode = "WRONGTYPE",
|
|
}
|
|
};
|
|
_transactionHistoryChecker = new DummyTransactionChecker();
|
|
var slip = new RepoAccountProcessingSlip()
|
|
{
|
|
TransactionHistory = transactions,
|
|
ExistingRepoAccount = new RepoAccount(),
|
|
UpdatedRepoAccount = new RepoAccount()
|
|
};
|
|
var result = _transactionHistoryChecker.CheckForAlert(slip);
|
|
|
|
Assert.Null(result);
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_Formatted_Message()
|
|
{
|
|
var transactions = new List<CoreTransaction>()
|
|
{
|
|
new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Now.AddDays(-5),
|
|
}
|
|
};
|
|
_transactionHistoryChecker = new DummyTransactionChecker();
|
|
var result = TransactionHistoryChecker.FormatTransactionMessage(new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Parse("1941-12-07"),
|
|
amount = 248.49M,
|
|
runningBalance = 2398.05M,
|
|
transactionTypeDescription = "Test",
|
|
transactionTypeCode = "TEST"
|
|
});
|
|
|
|
var expectedMessage =
|
|
"Transaction Type: \"TEST\" | Posting: 12/7/1941 12:00:00 AM | Transaction: $248.49 | Balance: $2,398.05 | Description: \"Test\"";
|
|
Assert.Equal(expectedMessage, result);
|
|
}
|
|
}
|
|
|
|
internal class DummyTransactionChecker : TransactionHistoryChecker
|
|
{
|
|
public override List<EventAlert> CheckForAlert(RepoAccountProcessingSlip slip)
|
|
{
|
|
var result = GetRecentTransactionsFromType(new List<string> { "TEST TRANSACTION" }, slip.TransactionHistory);
|
|
return result != null ? new List<EventAlert> { new EventAlert() } : null;
|
|
}
|
|
}
|
|
} |