127 lines
5.5 KiB
C#
127 lines
5.5 KiB
C#
using Moq;
|
|
using NUnit.Framework;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using LCU.Api.Internal.DataCleanUp.Services;
|
|
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
|
using LCU.Library.Internal.DataCleanUpModel.Enum;
|
|
using LCU.Library.Internal.DataCleanUpModel.Models;
|
|
using LCU.Api.Internal.DataCleanUp.Models;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreSoapResponses;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
|
using System;
|
|
using System.Linq;
|
|
using LCU.Api.Internal.DataCleanUp.Configuration;
|
|
|
|
namespace LCU.Api.Internal.DataCleanUpTest.Services
|
|
{
|
|
internal class BatchAddFundsToVipSavingsAccountsServiceTest
|
|
{
|
|
private BatchAddFundsToVipSavingsAccountsService _batchAddFundsToVipSavingsAccountsService;
|
|
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
|
private Mock<IFileOperationsService> _mockFileOperationsService;
|
|
private DataCleanupDefaults _dataCleanUpDefaults;
|
|
private SavingsMissingRequirementsDefaults _savingsDefaults;
|
|
private DataCleanUpConfiguration _dataCleanUpConfiguration;
|
|
private FileOperationsConfiguration _fileOperationsConfiguration;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_dataCleanUpConfiguration = new DataCleanUpConfiguration()
|
|
{
|
|
TimeZone = "America/Chicago"
|
|
};
|
|
|
|
_dataCleanUpDefaults = new DataCleanupDefaults()
|
|
{
|
|
MemberCheckHoldsUserFieldCode = "MBRH",
|
|
MemberCheckHoldsDays = 30,
|
|
BatchAddFunds = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\BatchAddFunds\\NeedToFund.csv",
|
|
BatchAddFundsSummarySourcePath = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\BatchAddFunds\\"
|
|
};
|
|
|
|
_savingsDefaults = new SavingsMissingRequirementsDefaults()
|
|
{
|
|
FundsToAccountDefaults = new FundsToAccountDefaults()
|
|
{
|
|
Description = "Vip Savings",
|
|
TransactionAmount = 5.00,
|
|
TransactionTypeCode = "DEP",
|
|
FundsDefaults = new FundsDefaults()
|
|
{
|
|
ClearingCategoryCode = "IMED",
|
|
FundAmount = 5.00,
|
|
FundTypeCode = "EL",
|
|
FundTypeDetailCode = "INTR"
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
|
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
|
_batchAddFundsToVipSavingsAccountsService = new
|
|
(_mockCoreApiWrapperService.Object, _mockFileOperationsService.Object, _dataCleanUpDefaults, _savingsDefaults);
|
|
}
|
|
|
|
[Test]
|
|
public async Task BatchAddFunds_Success()
|
|
{
|
|
string strFileData = "NEED TO FUND,Account Number,Member Number,Member Name,New Member,Major Code,Minor Code,Minor Description,Account Created Date,Intial FundingDate,Funding Amount,Funding Type,Trans Description,Promo Code" + "\r\n" +
|
|
"Yes,123456,3456789,Test Me,Y,SAV,SV01,VIP Savings,6/1/2022,6/2/2022,$5.00 ,New Account Deposit,," + "\r\n" +
|
|
"Yes,126786,376846,Test Me Again,Y,SAV,SV01,VIP Savings,6/1/2022,6/2/2022,$5.00,Deposit,," + "\r\n" +
|
|
"Yes,47478,57436868,Test Me Three,Y,SAV,SV01,VIP Savings,6/1/2022,6/2/2022,$5.00,External Deposit,,";
|
|
|
|
string testFilePath = _dataCleanUpDefaults.BatchAddFunds;
|
|
|
|
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
|
|
|
var basicResponse = new BasicResponse()
|
|
{
|
|
Success = true,
|
|
Errors = new List<string>()
|
|
};
|
|
|
|
var basicResponseList = new List<BasicResponse>() { basicResponse };
|
|
|
|
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()))
|
|
.ReturnsAsync(basicResponseList);
|
|
|
|
var testRequest = new DataCleanUpRequest()
|
|
{
|
|
CleanUpType = CleanUpTypes.BatchAddFundsToVipSavingsAccounts
|
|
};
|
|
var result = await _batchAddFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(testRequest, result.Request);
|
|
Assert.IsTrue(result.Successful);
|
|
Assert.IsEmpty(result.ResponseStack);
|
|
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Exactly(3));
|
|
|
|
}
|
|
|
|
[Test]
|
|
public async Task BatchAddFunds_Fail_MissingCSV()
|
|
{
|
|
string testFilePath = _dataCleanUpDefaults.BatchAddFunds;
|
|
|
|
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
|
|
|
var testRequest = new DataCleanUpRequest()
|
|
{
|
|
CleanUpType = CleanUpTypes.BatchAddFundsToVipSavingsAccounts
|
|
};
|
|
var result = await _batchAddFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(testRequest, result.Request);
|
|
Assert.IsFalse(result.Successful);
|
|
Assert.AreEqual(1, result.ResponseStack.Count());
|
|
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Never);
|
|
}
|
|
}
|
|
}
|