87 lines
2.9 KiB
C#
87 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using LCU.API.Collections.RepoApi.DataAccess;
|
|
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 Moq;
|
|
using Xunit;
|
|
|
|
namespace LCU.API.Collections.RepoApiTests.AlertCheckers
|
|
{
|
|
public class SaleFundsReceivedCheckerTest
|
|
{
|
|
private SaleFundsReceivedChecker _saleFundsReceivedChecker;
|
|
private List<CoreTransaction> _transactions;
|
|
private readonly Mock<ICoreDao> _mockCoreDao;
|
|
|
|
public SaleFundsReceivedCheckerTest()
|
|
{
|
|
_mockCoreDao = new Mock<ICoreDao>();
|
|
}
|
|
|
|
[Fact]
|
|
public void Creates_Alert_When_Description_Contains_Sub_string()
|
|
{
|
|
_mockCoreDao.Setup(service => service.RetrieveMemberAsync(It.IsAny<string>()))
|
|
.ReturnsAsync(
|
|
new MemberDetail()
|
|
{
|
|
MemberId = 8675309
|
|
}
|
|
);
|
|
|
|
_transactions = new List<CoreTransaction>()
|
|
{
|
|
new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Now.AddDays(-2),
|
|
transactionTypeCode = "PRCT",
|
|
amount = 500,
|
|
runningBalance = 2000,
|
|
transactionTypeDescription = "Sale Of Test"
|
|
}
|
|
};
|
|
_saleFundsReceivedChecker = new SaleFundsReceivedChecker();
|
|
var slip = new RepoAccountProcessingSlip()
|
|
{
|
|
TransactionHistory = _transactions,
|
|
ExistingRepoAccount = new RepoAccount(),
|
|
UpdatedRepoAccount = new RepoAccount()
|
|
};
|
|
|
|
var result = _saleFundsReceivedChecker.CheckForAlert(slip);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.Equal("Sale Funds Received", result[0].Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Does_Not_Create_Alert_When_Description_Does_Not_Contain_Sub_String()
|
|
{
|
|
_transactions = new List<CoreTransaction>()
|
|
{
|
|
new CoreTransaction()
|
|
{
|
|
postingDate = DateTime.Now.AddDays(-2),
|
|
transactionTypeCode = "SHOULDFAILTYPECODE",
|
|
amount = 500,
|
|
runningBalance = 2000,
|
|
transactionTypeDescription = "Test"
|
|
}
|
|
};
|
|
_saleFundsReceivedChecker = new SaleFundsReceivedChecker();
|
|
var slip = new RepoAccountProcessingSlip()
|
|
{
|
|
TransactionHistory = _transactions,
|
|
ExistingRepoAccount = new RepoAccount(),
|
|
UpdatedRepoAccount = new RepoAccount()
|
|
};
|
|
|
|
var result = _saleFundsReceivedChecker.CheckForAlert(slip);
|
|
|
|
Assert.Null(result);
|
|
}
|
|
}
|
|
} |