136 lines
5.2 KiB
C#
136 lines
5.2 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.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
|
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
|
using LCU.Library.Internal.DataCleanUpModel.Entities;
|
|
using LCU.Api.Internal.DataCleanUpLib.Repositories;
|
|
using LCU.Api.Internal.DataCleanUp.Configuration;
|
|
|
|
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
|
|
|
public class UpdateAccountLoanToValueServiceTest
|
|
{
|
|
private UpdateAccountLoanToValueService _updateAccountLoanToValueService;
|
|
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
|
private Mock<ICoreApiWrapperDao> _mockCoreApiWrapperDao;
|
|
private Mock<ILtvDataCleanUpRepository> _mockLtvDataCleanUpRepository;
|
|
private DataCleanupDefaults _dataCleanUpDefaults;
|
|
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
|
|
_dataCleanUpDefaults = new DataCleanupDefaults()
|
|
{
|
|
LtvExcludedMinorAccountTypes = new List<string>() { "DL01", "DL02", "DL03", "DL04", "DL05", "DL06", "DL07", "DL08", "DL09", "DL10", "DL11", "DL12", "DL13", "DL14", "DL15", "DL16" }
|
|
};
|
|
|
|
_mockCoreApiWrapperDao = new Mock<ICoreApiWrapperDao>();
|
|
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
|
_mockLtvDataCleanUpRepository = new Mock<ILtvDataCleanUpRepository>();
|
|
_updateAccountLoanToValueService = new UpdateAccountLoanToValueService(_mockCoreApiWrapperService.Object, _mockLtvDataCleanUpRepository.Object, _dataCleanUpDefaults);
|
|
}
|
|
|
|
[Test]
|
|
public async Task CleanUpLoanToValue_Success()
|
|
{
|
|
|
|
// Arrange
|
|
_mockLtvDataCleanUpRepository.Setup(ltvDataCleanUpRepository => ltvDataCleanUpRepository.ListMinorAccountTypeAsync(_dataCleanUpDefaults.LtvExcludedMinorAccountTypes)).ReturnsAsync(
|
|
new List<Ltv_DataCleanUp>()
|
|
{
|
|
new Ltv_DataCleanUp()
|
|
});
|
|
|
|
//Set Up Response
|
|
var basicResponse = new BasicResponse()
|
|
{
|
|
Success = true,
|
|
Errors = new List<string>()
|
|
};
|
|
|
|
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountLoanToValue(It.IsAny<string>(), It.IsAny<double>()))
|
|
.ReturnsAsync(basicResponse);
|
|
|
|
var testRequest = new DataCleanUpRequest()
|
|
{
|
|
CleanUpType = CleanUpTypes.UpdateAccountLoanToValue
|
|
};
|
|
var result = await _updateAccountLoanToValueService.CleanUp(testRequest);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(testRequest, result.Request);
|
|
Assert.IsTrue(result.Successful);
|
|
Assert.IsEmpty(result.ResponseStack);
|
|
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountLoanToValue(It.IsAny<string>(), It.IsAny<double>()), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public async Task CleanUpLoanToValue_Success_FilterIndirectAccountType()
|
|
{
|
|
|
|
// Arrange
|
|
_mockLtvDataCleanUpRepository.Setup(ltvDataCleanUpRepository => ltvDataCleanUpRepository.ListMinorAccountTypeAsync(_dataCleanUpDefaults.LtvExcludedMinorAccountTypes)).ReturnsAsync(
|
|
new List<Ltv_DataCleanUp>()
|
|
{
|
|
new Ltv_DataCleanUp()
|
|
{
|
|
AccountNumber = "1111111",
|
|
Ltv = .1,
|
|
MinorType = "DL01"
|
|
}
|
|
});
|
|
|
|
//Set Up Response
|
|
var basicResponse = new BasicResponse()
|
|
{
|
|
Success = true,
|
|
Errors = new List<string>()
|
|
};
|
|
|
|
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountLoanToValue(It.IsAny<string>(), It.IsAny<double>()))
|
|
.ReturnsAsync(basicResponse);
|
|
|
|
var testRequest = new DataCleanUpRequest()
|
|
{
|
|
CleanUpType = CleanUpTypes.UpdateAccountLoanToValue
|
|
};
|
|
var result = await _updateAccountLoanToValueService.CleanUp(testRequest);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(testRequest, result.Request);
|
|
Assert.IsTrue(result.Successful);
|
|
Assert.IsEmpty(result.ResponseStack);
|
|
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountLoanToValue(It.IsAny<string>(), It.IsAny<double>()), Times.Once);
|
|
_mockCoreApiWrapperDao.Verify(x => x.UpdateAccountLoanToValue(It.IsAny<AccountLtvUpdateRequest>()), Times.Never);
|
|
}
|
|
|
|
[Test]
|
|
public async Task CleanUp_LoanToValue_Fail()
|
|
{
|
|
//Set Up Object
|
|
var basicResponse = new BasicResponse();
|
|
|
|
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountLoanToValue(It.IsAny<string>(), 0))
|
|
.ReturnsAsync(basicResponse);
|
|
|
|
var testRequest = new DataCleanUpRequest()
|
|
{
|
|
CleanUpType = CleanUpTypes.UpdateAccountLoanToValue
|
|
};
|
|
var result = await _updateAccountLoanToValueService.CleanUp(testRequest);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.AreEqual(testRequest, result.Request);
|
|
Assert.AreEqual(0, result.ResponseStack.Count);
|
|
_mockCoreApiWrapperDao.Verify(x => x.UpdateAccountLoanToValue(It.IsAny<AccountLtvUpdateRequest>()), Times.Never);
|
|
}
|
|
}
|