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 CreditAdjustmentCheckerTest { private readonly CreditAdjustmentChecker _creditAdjustmentChecker; private readonly List _transactions; public CreditAdjustmentCheckerTest() { _transactions = new List() { new CoreTransaction() { postingDate = DateTime.Now.AddDays(-2), transactionTypeCode = "PDSB", amount = 500, runningBalance = 2000, transactionTypeDescription = "Test" } }; _creditAdjustmentChecker = new CreditAdjustmentChecker(); } [Fact] public void Creates_Alert_With_Recent_Transactions_Present_And_O4R_Status() { var slip = new RepoAccountProcessingSlip() { TransactionHistory = _transactions, ExistingRepoAccount = new RepoAccount(), UpdatedRepoAccount = new RepoAccount { Status = "O4R" } }; var result = _creditAdjustmentChecker.CheckForAlert(slip); Assert.NotNull(result); Assert.Equal("Credit Adjustment Received", result[0].Message); } [Fact] public void Creates_Alert_With_Recent_Transactions_Present_And_REPO_Status() { var slip = new RepoAccountProcessingSlip() { TransactionHistory = _transactions, ExistingRepoAccount = new RepoAccount(), UpdatedRepoAccount = new RepoAccount { Status = "REPO" } }; var result = _creditAdjustmentChecker.CheckForAlert(slip); Assert.NotNull(result); Assert.Equal("Credit Adjustment Received", result[0].Message); } [Fact] public void Creates_Alert_With_Recent_Transactions_Present_And_SOLD_Status() { var slip = new RepoAccountProcessingSlip() { TransactionHistory = _transactions, ExistingRepoAccount = new RepoAccount(), UpdatedRepoAccount = new RepoAccount { Status = "SOLD" } }; var result = _creditAdjustmentChecker.CheckForAlert(slip); Assert.NotNull(result); Assert.Equal("Credit Adjustment Received", result[0].Message); } [Fact] public void Does_Not_Create_Alert_For_Unwatched_Statuses() { var slip = new RepoAccountProcessingSlip() { TransactionHistory = _transactions, ExistingRepoAccount = new RepoAccount(), UpdatedRepoAccount = new RepoAccount { Status = "RECA" } }; var result = _creditAdjustmentChecker.CheckForAlert(slip); Assert.Null(result); } } }