Adding
This commit is contained in:
+430
@@ -0,0 +1,430 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using TestTool = Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Library.Internal.ApiSecurity.Enums;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessTypes;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.DataAccess;
|
||||
|
||||
public class CoreApiWrapperDaoTest
|
||||
{
|
||||
private const string ClientKeyValue = "DataCleanUp";
|
||||
private Mock<IGetRequest> _mockgetRequest;
|
||||
private Mock<IPostRequest> _mockpostRequest;
|
||||
private Mock<IPutRequest> _mockputRequest;
|
||||
private CoreApiWrapperDao _coreApiWrapperDaoWithSecurityKey;
|
||||
private CoreApiWrapperDao _coreApiWrapperDaoWithoutSecurityKey;
|
||||
|
||||
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithInternalKey = new ApiSecurityConfiguration()
|
||||
{
|
||||
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
|
||||
ExternalApiKeySet = new Dictionary<string, string>(),
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
{ ClientKeyValue, "some_guid-1234-5666" }
|
||||
}
|
||||
};
|
||||
|
||||
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithoutInternalKey = new ApiSecurityConfiguration()
|
||||
{
|
||||
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
|
||||
ExternalApiKeySet = new Dictionary<string, string>(),
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
};
|
||||
|
||||
private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration = new CoreApiWrapperConfiguration()
|
||||
{
|
||||
CoreApiWrapperUrl = "https://localhost:44364",
|
||||
AccessChannelPersons = "/api/core/AccessChannelPersons",
|
||||
AccesschannelPersonWithIncludes = "/api/core/AccessChannelPersons/GetWithIncludes",
|
||||
PostFundsToAccount = "/api/core/Transaction/PostFundsToAccount",
|
||||
PutAccountNickNameUpdateRequest = "/api/core/Account/PutAccountNickNameUpdateRequest",
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockpostRequest = new Mock<IPostRequest>();
|
||||
_mockputRequest = new Mock<IPutRequest>();
|
||||
_mockgetRequest = new Mock<IGetRequest>();
|
||||
_coreApiWrapperDaoWithSecurityKey = new CoreApiWrapperDao(_apiSecurityConfigurationWithInternalKey, _coreApiWrapperConfiguration, _mockpostRequest.Object, _mockputRequest.Object, _mockgetRequest.Object);
|
||||
_coreApiWrapperDaoWithoutSecurityKey = new CoreApiWrapperDao(_apiSecurityConfigurationWithoutInternalKey, _coreApiWrapperConfiguration, _mockpostRequest.Object, _mockputRequest.Object, _mockgetRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRequest_GetCoreApiMessageAccessChannelPersonsWithIncludesSecurityKeys_Success()
|
||||
{
|
||||
|
||||
var accessChannelPersonsByPersonRequest = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
PersonNumber = 145,
|
||||
ActiveOnly = true,
|
||||
IncludeCards = false
|
||||
};
|
||||
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockgetRequest.Setup(x => x.AsyncWithNewton<CoreApiMessage<IEnumerable<AccessChannelPerson>>>(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(),It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(coreApiMessage).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.GetCoreApiMessageAccessChannelPersons(accessChannelPersonsByPersonRequest, testPersonNumbers);
|
||||
|
||||
Assert.IsNotNull(response);
|
||||
Assert.AreEqual(2, response.MessageBody.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRequest_GetCoreApiMessageAccessChannelPersonsWithIncludesSecurityKeys_NoResponse()
|
||||
{
|
||||
|
||||
var accessChannelPersonsByPersonRequest = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.GetCoreApiMessageAccessChannelPersons(accessChannelPersonsByPersonRequest, testPersonNumbers);
|
||||
Assert.IsNotNull(_mockgetRequest);
|
||||
Assert.AreEqual(null, response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRequest_GetCoreApiMessageAccessChannelPersonsWithSecurityKeys_Success()
|
||||
{
|
||||
var accessChannelPersonsByPersonRequest = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
PersonNumber = 145,
|
||||
ActiveOnly = true,
|
||||
IncludeCards = false
|
||||
};
|
||||
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockgetRequest.Setup(x => x.Async<CoreApiMessage<IEnumerable<AccessChannelPerson>>>(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(coreApiMessage).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.GetCoreApiMessageAccessChannelPersons(accessChannelPersonsByPersonRequest);
|
||||
|
||||
Assert.IsNotNull(_mockgetRequest);
|
||||
Assert.IsNotNull(response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRequest_GetCoreApiMessageAccessChannelPersonsWithKeys_NoResponse()
|
||||
{
|
||||
var accessChannelPersonsByPersonRequest = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.GetCoreApiMessageAccessChannelPersons(accessChannelPersonsByPersonRequest);
|
||||
|
||||
Assert.IsNotNull(_mockgetRequest);
|
||||
Assert.AreEqual(null, response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PostRequest_PostFundsWithSecurityKeys_Success()
|
||||
{
|
||||
var listFundsRequest = new List<FundsToAccountRequest>()
|
||||
{
|
||||
new FundsToAccountRequest()
|
||||
{
|
||||
AccountNumber = 111,
|
||||
Description = "Test",
|
||||
TransactionAmount = 4 * -1,
|
||||
TransactionTypeCode = "MOB",
|
||||
FundRequests = new List<FundRequest>()
|
||||
{
|
||||
new FundRequest()
|
||||
{
|
||||
ClearingCategoryCode = "Test",
|
||||
FundAmount = 4 * -1,
|
||||
FundTypeCode = "Test",
|
||||
FundTypeDetailCode = "Test"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
new FundsToAccountRequest()
|
||||
{
|
||||
AccountNumber = 222,
|
||||
Description = "Test2",
|
||||
TransactionAmount = 4,
|
||||
TransactionTypeCode = "DEP",
|
||||
FundRequests = new List<FundRequest>()
|
||||
{
|
||||
new FundRequest()
|
||||
{
|
||||
ClearingCategoryCode = "Test",
|
||||
FundAmount = 4,
|
||||
FundTypeCode = "Test",
|
||||
FundTypeDetailCode = "Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponse };
|
||||
|
||||
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.PostFundsToAccount}";
|
||||
var uri = new Uri(path);
|
||||
|
||||
_mockpostRequest.Setup(x => x.Async<List<FundsToAccountRequest>, List<BasicResponse>>(It.IsAny<Uri>(), It.IsAny<List<FundsToAccountRequest>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(basicResponseList).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.PostFundsToAccount(listFundsRequest);
|
||||
|
||||
Assert.IsNotNull(_mockpostRequest);
|
||||
Assert.AreEqual(true, response[0].Success);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestTool.ExpectedException(typeof(System.Exception), AllowDerivedTypes=true)]
|
||||
public async Task PostRequest_PostFundsWithOutSecurityKeys_Exception()
|
||||
{
|
||||
var listFundsRequest = new List<FundsToAccountRequest>()
|
||||
{
|
||||
new FundsToAccountRequest()
|
||||
{
|
||||
AccountNumber = 111,
|
||||
Description = "Test",
|
||||
TransactionAmount = 4 * -1,
|
||||
TransactionTypeCode = "MOB",
|
||||
FundRequests = new List<FundRequest>()
|
||||
{
|
||||
new FundRequest()
|
||||
{
|
||||
ClearingCategoryCode = "Test",
|
||||
FundAmount = 4 * -1,
|
||||
FundTypeCode = "Test",
|
||||
FundTypeDetailCode = "Test"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
new FundsToAccountRequest()
|
||||
{
|
||||
AccountNumber = 222,
|
||||
Description = "Test2",
|
||||
TransactionAmount = 4,
|
||||
TransactionTypeCode = "DEP",
|
||||
FundRequests = new List<FundRequest>()
|
||||
{
|
||||
new FundRequest()
|
||||
{
|
||||
ClearingCategoryCode = "Test",
|
||||
FundAmount = 4,
|
||||
FundTypeCode = "Test",
|
||||
FundTypeDetailCode = "Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.That(() => _coreApiWrapperDaoWithoutSecurityKey.PostFundsToAccount(listFundsRequest),
|
||||
Throws.TypeOf<Exception>()); //Message will be Your Internal Key is Missing
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PutRequest_PutAccountNickNameWithSecurityKeys_Success()
|
||||
{
|
||||
var request = new AccountNickNameUpdateRequest()
|
||||
{
|
||||
AccountDescription = "Test",
|
||||
AccountNumber = 1,
|
||||
};
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
_mockputRequest.Setup(x => x.Async<AccountNickNameUpdateRequest, BasicResponse>(It.IsAny<Uri>(), It.IsAny<AccountNickNameUpdateRequest>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(basicResponse).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.PutAccountNicknameUpdateRequest(request);
|
||||
|
||||
Assert.IsNotNull(_mockputRequest);
|
||||
Assert.AreEqual(true, response.Success);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PutRequest_PutAccountUserField_Success()
|
||||
{
|
||||
var request = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
UserFieldCode = "PLNB",
|
||||
AccountNumber = 1,
|
||||
Value = "CC2233"
|
||||
}
|
||||
};
|
||||
|
||||
var userFieldResponse = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
UserFieldCode = "PLNB",
|
||||
AccountNumber = 1,
|
||||
Value = "CC2233"
|
||||
}
|
||||
};
|
||||
|
||||
_mockputRequest.Setup(x => x.Async<List<AccountUserField>, IEnumerable<AccountUserField>>(It.IsAny<Uri>(), It.IsAny<List<AccountUserField>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(userFieldResponse).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.PutAccountUserField(request);
|
||||
|
||||
Assert.IsNotNull(_mockputRequest);
|
||||
Assert.AreEqual(1, response.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PostRequest_PostAccountUserField_Success()
|
||||
{
|
||||
var request = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
UserFieldCode = "PLDT",
|
||||
AccountNumber = 1,
|
||||
Value = "6/1/2023"
|
||||
}
|
||||
};
|
||||
|
||||
var userFieldResponse = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
UserFieldCode = "PLDT",
|
||||
AccountNumber = 1,
|
||||
Value = "6/1/2023"
|
||||
}
|
||||
};
|
||||
|
||||
_mockpostRequest.Setup(x => x.Async<List<AccountUserField>, IEnumerable<AccountUserField>>(It.IsAny<Uri>(), It.IsAny<List<AccountUserField>>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(userFieldResponse).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.PostAccountUserField(request);
|
||||
|
||||
Assert.IsNotNull(_mockpostRequest);
|
||||
Assert.AreEqual(1, response.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetRequest_GetAccountUserField_Success()
|
||||
{
|
||||
var acctNbr = 993934933333333;
|
||||
|
||||
var userFieldResponse = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
UserFieldCode = "PLDT",
|
||||
AccountNumber = 993934933333333,
|
||||
Value = "6/1/2023"
|
||||
}
|
||||
};
|
||||
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccountUserField>>(coreMessageHeader, userFieldResponse);
|
||||
_mockgetRequest.Setup(x => x.AsyncWithNewton<CoreApiMessage<IEnumerable<AccountUserField>>>(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(coreApiMessage).Verifiable();
|
||||
|
||||
var response = await _coreApiWrapperDaoWithSecurityKey.GetAccountUserField(acctNbr);
|
||||
|
||||
Assert.IsNotNull(_mockgetRequest);
|
||||
Assert.AreEqual(1, response.Count());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.DataAccess;
|
||||
|
||||
public class FileOperationsDaoTest
|
||||
{
|
||||
private Mock<IGetRequest> _mockgetRequest;
|
||||
private Mock<IPostRequest> _mockpostRequest;
|
||||
private FileOperationsDao _fileOperationsDao;
|
||||
|
||||
private readonly FileOperationsConfiguration _fileOperationsConfiguration = new FileOperationsConfiguration()
|
||||
{
|
||||
FileOperationsUrl = "https://localhost:44555",
|
||||
GetFile = "/api/FileOperations/",
|
||||
WriteFile = "/api/FileOperations/WriteFileData",
|
||||
BuildDynamicFileList = "/DynamicFile/BuildDynamicFileList"
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockpostRequest = new Mock<IPostRequest>();
|
||||
_mockgetRequest = new Mock<IGetRequest>();
|
||||
_fileOperationsDao = new FileOperationsDao(_fileOperationsConfiguration, _mockpostRequest.Object, _mockgetRequest.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetFileContentTest_Success()
|
||||
{
|
||||
var filename = "testfile.txt";
|
||||
var finalFilePath = new string($"{_fileOperationsConfiguration.GetFile}{filename}");
|
||||
var testContents = "This is my file content.";
|
||||
|
||||
_mockgetRequest.Setup(x => x.StringResponseAsync(It.IsAny<Uri>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(testContents).Verifiable();
|
||||
|
||||
var response = await _fileOperationsDao.GetFileContent(finalFilePath);
|
||||
|
||||
Assert.IsNotNull(response);
|
||||
Assert.AreEqual("This is my file content.", response);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task WriteFileTest_Success()
|
||||
{
|
||||
var writeFileRequest = new WriteFileRequest()
|
||||
{
|
||||
DestinationPath = "/testDestination",
|
||||
FileName = "mytestfile.txt"
|
||||
};
|
||||
|
||||
var path = $"{_fileOperationsConfiguration.FileOperationsUrl}{_fileOperationsConfiguration.WriteFile}";
|
||||
var uri = new Uri(path);
|
||||
|
||||
var listStringFiles = new List<string>()
|
||||
{
|
||||
"Testcleanupfile.csv",
|
||||
"Testcleanupfile.pdf"
|
||||
};
|
||||
|
||||
_mockpostRequest.Setup(x => x.AsyncWithNewton<WriteFileRequest, List<string>>(It.IsAny<Uri>(), It.IsAny<WriteFileRequest>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(listStringFiles).Verifiable();
|
||||
|
||||
var response = await _fileOperationsDao.WriteFile(writeFileRequest);
|
||||
Assert.IsNotNull(response);
|
||||
_mockpostRequest.Verify();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BuildDynamicFileList_Success()
|
||||
{
|
||||
var dynamicFileListRequest = new DynamicFileListRequest()
|
||||
{
|
||||
DynamicFileSettings = new DynamicNameSetting
|
||||
{
|
||||
DateFormatSettings = null,
|
||||
DaysFromToday = 0,
|
||||
RegexSettings = null,
|
||||
},
|
||||
Filename = "mytestfile.txt",
|
||||
Path = "//network/Test/"
|
||||
};
|
||||
|
||||
var listStringFiles = new List<string>()
|
||||
{
|
||||
"Testfile.csv",
|
||||
"Testfile.pdf"
|
||||
};
|
||||
|
||||
var path = $"{_fileOperationsConfiguration.FileOperationsUrl}{_fileOperationsConfiguration.BuildDynamicFileList}";
|
||||
var uri = new Uri(path);
|
||||
|
||||
_mockpostRequest.Setup(x => x.Async<DynamicFileListRequest,List<string>>(It.IsAny<Uri>(), It.IsAny<DynamicFileListRequest>(), It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(listStringFiles).Verifiable();
|
||||
|
||||
var response = await _fileOperationsDao.BuildDynamicFileList(dynamicFileListRequest);
|
||||
|
||||
Assert.IsNotNull(response);
|
||||
Assert.AreEqual(2, response.Count());
|
||||
Assert.AreEqual("Testfile.pdf", response.Last());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1701;1702;8604;8605</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<NoWarn>1701;1702;8604;8605</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Library.Internal.ApiSecurity" Version="1.0.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.CoreApiWrapperModel" Version="2.27.14" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuHttpClient" Version="1.17.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LCU.Api.Internal.DataCleanUp\LCU.Api.Internal.DataCleanUp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Repositories\loanToValue_repo.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Entities;
|
||||
using LCU.Api.Internal.DataCleanUpLib.Persistence;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.RepositoryTests;
|
||||
|
||||
public class DbContextTestSet
|
||||
{
|
||||
public IReadOnlyCollection<Ltv_DataCleanUp>? Ltv_DataCleanUps { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public abstract class DbContextFromJsonTest
|
||||
{
|
||||
private const string RepositoryFolder = "Repositories";
|
||||
private const string LtvFileName = "loanToValue_repo";
|
||||
public DbContextTestSet GetTestRecords()
|
||||
{
|
||||
var testSet = new DbContextTestSet();
|
||||
|
||||
// Get the absolute path to the JSON file
|
||||
var basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
|
||||
var path = $"{ basePath}//{RepositoryFolder}//{LtvFileName}.json";
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
throw new ArgumentException($"Could not find file at path: {path}");
|
||||
}
|
||||
|
||||
var fileData = File.ReadAllText(path);
|
||||
var allData = JObject.Parse(fileData);
|
||||
|
||||
var data = allData["Ltv_DataCleanUps"];
|
||||
testSet.Ltv_DataCleanUps = data.ToObject<List<Ltv_DataCleanUp>>();
|
||||
|
||||
return testSet;
|
||||
}
|
||||
|
||||
public AppDbContext GetBlankContext()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseInMemoryDatabase(Guid.NewGuid().ToString())
|
||||
.Options;
|
||||
return new AppDbContext(options);
|
||||
}
|
||||
|
||||
public AppDbContext GetContextWithData()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseInMemoryDatabase(Guid.NewGuid().ToString())
|
||||
.Options;
|
||||
var context = new AppDbContext(options);
|
||||
|
||||
var testData = GetTestRecords();
|
||||
AddTo(context.LtvDataCleanUp, testData.Ltv_DataCleanUps);
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private static void AddTo<T>(DbSet<T> collection, IEnumerable<T> range) where T : class
|
||||
{
|
||||
if (range != null) collection.AddRange(range);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
using LCU.Api.Internal.DataCleanUpLib.Repositories;
|
||||
using LCU.Api.Internal.DataCleanUpTest.RepositoryTests;
|
||||
using Xunit;
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Repositories;
|
||||
public class UpdateAccountLoanToValueRepositoryTest : DbContextFromJsonTest
|
||||
{
|
||||
private readonly LtvDataCleanUpRepository _ltvRepository;
|
||||
private readonly Mock<DataCleanupDefaults> _mockDataCleanupDefaults;
|
||||
|
||||
|
||||
public UpdateAccountLoanToValueRepositoryTest()
|
||||
|
||||
{
|
||||
var dbContext = GetContextWithData();
|
||||
_mockDataCleanupDefaults = new Mock<DataCleanupDefaults>();
|
||||
_mockDataCleanupDefaults.Object.LtvExcludedMinorAccountTypes = new List <string>()
|
||||
{
|
||||
"DL01", "DL02", "DL03", "DL04", "DL05", "DL06", "DL07", "DL08", "DL09", "DL10", "DL11", "DL12", "DL13", "DL14", "DL15", "DL16"
|
||||
};
|
||||
|
||||
_ltvRepository = new LtvDataCleanUpRepository(dbContext);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void ExcludedListAsync_Return_1() //DL01 minor account type is filtered
|
||||
{
|
||||
var resultsBasic = await _ltvRepository.ListMinorAccountTypeAsync(_mockDataCleanupDefaults.Object.LtvExcludedMinorAccountTypes);
|
||||
|
||||
//Assert
|
||||
Assert.NotNull(resultsBasic);
|
||||
Assert.Single(resultsBasic);
|
||||
Assert.Equal("SV01", resultsBasic.First().MinorType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"Ltv_DataCleanUps": [
|
||||
{
|
||||
"AccountNumber": "1111111",
|
||||
"Ltv": ".1",
|
||||
"MinorType": "DL01"
|
||||
},
|
||||
{
|
||||
"AccountNumber": "2222222",
|
||||
"Ltv": ".2",
|
||||
"MinorType": "SV01"
|
||||
}
|
||||
]
|
||||
}
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.Models;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Enum;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class AddFundsToIndirectSavingsAccountsServiceTest
|
||||
{
|
||||
private AddFundsToIndirectSavingsAccountsService _addFundsToIndirectSavingsAccountsService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
private DataCleanUpConfiguration _dataCleanUpConfiguration;
|
||||
private IndirectSavingsRequirementsDefaults _indirectSavingsRequirementsDefaults;
|
||||
private DataCleanUpResult _dataCleanUpResult;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dataCleanUpConfiguration = new DataCleanUpConfiguration()
|
||||
{
|
||||
TimeZone = "America/Chicago"
|
||||
};
|
||||
|
||||
_indirectSavingsRequirementsDefaults = new IndirectSavingsRequirementsDefaults()
|
||||
{
|
||||
Description = "test",
|
||||
GLAccountNumber = "123445",
|
||||
TransactionAmount = 5.00,
|
||||
TransactionTypeCode = "test",
|
||||
TransactionTypeCodeDeposit = "test",
|
||||
TransactionTypeCodeGL = "test",
|
||||
FundsDefaults = new FundsDefaults()
|
||||
{
|
||||
ClearingCategoryCode = "IMED",
|
||||
FundAmount = 5.00,
|
||||
FundTypeCode = "EL",
|
||||
FundTypeDetailCode = "INTR"
|
||||
},
|
||||
FundingCoreRequests = new FundingCoreRequests()
|
||||
{
|
||||
AccountStatusTypes = new List<string>() { "APPR" },
|
||||
BranchCodeTypes = new List<long>() { 1310 },
|
||||
MajorAccountTypes = new List<string>() { "SAV" },
|
||||
MinorAccountTypes = new List<string>() { "SV01", "BS01" }
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_addFundsToIndirectSavingsAccountsService = new AddFundsToIndirectSavingsAccountsService(_mockCoreApiWrapperService.Object,
|
||||
_mockFileOperationsService.Object,
|
||||
_indirectSavingsRequirementsDefaults,
|
||||
_dataCleanUpConfiguration);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleCleanUp_Ok()
|
||||
{
|
||||
var indirectRequest = new IndirectFundingRequest()
|
||||
{
|
||||
Filename = "Test",
|
||||
SummaryFileDestinationPath = "Test"
|
||||
};
|
||||
|
||||
var dataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToIndirectSavingsAccounts,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(indirectRequest)
|
||||
};
|
||||
|
||||
var response = new List<AccountsByMajorMinorBranchAndStatusResponse>()
|
||||
{
|
||||
new AccountsByMajorMinorBranchAndStatusResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BranchCode = 1,
|
||||
Name = "Test"
|
||||
}
|
||||
};
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponse };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAccountsByMajorMinorBranchAndStatus(It.IsAny<AccountsByMajorMinorBranchAndStatusRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(It.IsAny<List<FundsToAccountRequest>>()))
|
||||
.ReturnsAsync(basicResponseList).Verifiable();
|
||||
|
||||
var result = await _addFundsToIndirectSavingsAccountsService.CleanUp(dataCleanUpRequest);
|
||||
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<List<FundsToAccountRequest>>()), Times.Exactly(1));
|
||||
|
||||
Assert.AreEqual(0, result.ResponseStack.Count());
|
||||
Assert.AreEqual(true, result.Successful);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleCleanUp_WithError()
|
||||
{
|
||||
var accountToBeFunded = new AccountsByMajorMinorBranchAndStatusResponse()
|
||||
{
|
||||
BranchCode = 1,
|
||||
AccountNumber = 1,
|
||||
Name = "Test"
|
||||
};
|
||||
|
||||
var response = new List<AccountsByMajorMinorBranchAndStatusResponse>()
|
||||
{
|
||||
new AccountsByMajorMinorBranchAndStatusResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BranchCode = 1,
|
||||
Name = "Test"
|
||||
}
|
||||
};
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToIndirectSavingsAccounts,
|
||||
DataCleanUpPayload = null
|
||||
};
|
||||
|
||||
_dataCleanUpResult = new DataCleanUpResult(testRequest, true, new List<string>());
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAccountsByMajorMinorBranchAndStatus(It.IsAny<AccountsByMajorMinorBranchAndStatusRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
var result = await _addFundsToIndirectSavingsAccountsService.HandleSavingsToFundsRequest(_dataCleanUpResult, accountToBeFunded);
|
||||
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
Assert.AreEqual(false, result.Successful);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleExportResultsFile_Ok_NoErrors()
|
||||
{
|
||||
var indirectRequest = new IndirectFundingRequest()
|
||||
{
|
||||
Filename = "Test",
|
||||
SummaryFileDestinationPath = "Test"
|
||||
};
|
||||
|
||||
var indirectSavingsAccountSummaryList = new List<IndirectSavingsAccountsSummary>
|
||||
{
|
||||
new IndirectSavingsAccountsSummary
|
||||
{
|
||||
AccountNumber = "1",
|
||||
BranchCode = "1",
|
||||
AmountFunded = _indirectSavingsRequirementsDefaults.FundsDefaults.FundAmount.ToString(),
|
||||
ErrorMessage = string.Empty,
|
||||
Name = "Test",
|
||||
}
|
||||
};
|
||||
|
||||
var summaryTotalResults = new IndirectSavingsAccountResult
|
||||
{
|
||||
TotalAccountsFunded = "1",
|
||||
TotalAccountsNotFunded = "0"
|
||||
};
|
||||
|
||||
await _addFundsToIndirectSavingsAccountsService.HandleExportResultsAddFundsToSavingsAccounts(indirectRequest);
|
||||
|
||||
Assert.AreEqual(0, indirectSavingsAccountSummaryList.Where(x => x.ErrorMessage == null).Count());
|
||||
Assert.AreEqual(summaryTotalResults.TotalAccountsFunded, indirectSavingsAccountSummaryList.Count().ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleExportResultsFile_Ok_WithErrors()
|
||||
{
|
||||
var indirectRequest = new IndirectFundingRequest()
|
||||
{
|
||||
Filename = "Test",
|
||||
SummaryFileDestinationPath = "Test"
|
||||
};
|
||||
|
||||
var indirectSavingsAccountSummaryList = new List<IndirectSavingsAccountsSummary>
|
||||
{
|
||||
new IndirectSavingsAccountsSummary
|
||||
{
|
||||
AccountNumber = "1",
|
||||
BranchCode = "1",
|
||||
AmountFunded = _indirectSavingsRequirementsDefaults.FundsDefaults.FundAmount.ToString(),
|
||||
ErrorMessage = "There was a problem funding the account",
|
||||
Name = "Test",
|
||||
}
|
||||
};
|
||||
|
||||
var summaryTotalResults = new IndirectSavingsAccountResult
|
||||
{
|
||||
TotalAccountsFunded = "0",
|
||||
TotalAccountsNotFunded = "1"
|
||||
};
|
||||
|
||||
await _addFundsToIndirectSavingsAccountsService.HandleExportResultsAddFundsToSavingsAccounts(indirectRequest);
|
||||
|
||||
Assert.AreEqual(1, indirectSavingsAccountSummaryList.Where(x => x.ErrorMessage != null).Count());
|
||||
Assert.AreEqual(summaryTotalResults.TotalAccountsNotFunded, indirectSavingsAccountSummaryList.Count().ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleCreatingAccountSummary_Ok_NoErrors()
|
||||
{
|
||||
var accountToBeFunded = new AccountsByMajorMinorBranchAndStatusResponse()
|
||||
{
|
||||
BranchCode = 1,
|
||||
AccountNumber = 1,
|
||||
Name = "Test"
|
||||
};
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToIndirectSavingsAccounts,
|
||||
DataCleanUpPayload = null
|
||||
};
|
||||
|
||||
_dataCleanUpResult = new DataCleanUpResult(testRequest, true, new List<string>());
|
||||
|
||||
var result = _addFundsToIndirectSavingsAccountsService.HandleCreatingAccountSummary(accountToBeFunded, _dataCleanUpResult);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(true, _dataCleanUpResult.Successful);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleCreatingAccountSummary_Ok_WithErrors()
|
||||
{
|
||||
var accountToBeFunded = new AccountsByMajorMinorBranchAndStatusResponse()
|
||||
{
|
||||
BranchCode = 1,
|
||||
AccountNumber = 1,
|
||||
Name = "Test"
|
||||
};
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToIndirectSavingsAccounts,
|
||||
DataCleanUpPayload = null
|
||||
};
|
||||
|
||||
var errorList = new List<string>()
|
||||
{
|
||||
"There was an error"
|
||||
};
|
||||
|
||||
_dataCleanUpResult = new DataCleanUpResult(testRequest, false, errorList);
|
||||
|
||||
var result = _addFundsToIndirectSavingsAccountsService.HandleCreatingAccountSummary(accountToBeFunded, _dataCleanUpResult);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(false, _dataCleanUpResult.Successful);
|
||||
Assert.IsNotNull(result.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
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.Api.Internal.DataCleanUp.Configuration;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class AddFundsToVipSavingsAccountsServiceTest
|
||||
{
|
||||
private AddFundsToVipSavingsAccountsService _addFundsToVipSavingsAccountsService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<ICoreApiWrapperDao> _mockCoreApiWrapperDao;
|
||||
private SavingsMissingRequirementsDefaults _savingsMissingRequirementsDefaults;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_savingsMissingRequirementsDefaults = 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"
|
||||
}
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperDao = new Mock<ICoreApiWrapperDao>();
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_addFundsToVipSavingsAccountsService = new AddFundsToVipSavingsAccountsService(_mockCoreApiWrapperService.Object, _savingsMissingRequirementsDefaults);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpVipSavings_Success()
|
||||
{
|
||||
//Set Up Object
|
||||
var listAccounts = new List<string>() { "1111111" };
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetVipSavingsToFund()).ReturnsAsync(listAccounts);
|
||||
|
||||
//Set Up Response
|
||||
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.AddFundsToVipSavingsAccounts
|
||||
};
|
||||
var result = await _addFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetVipSavingsToFund(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_GetVipSavings_Null_Fail()
|
||||
{
|
||||
//Set Up Object
|
||||
List<string> listAccounts = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetVipSavingsToFund()).ReturnsAsync(listAccounts);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToVipSavingsAccounts
|
||||
};
|
||||
var result = await _addFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetVipSavingsToFund(), Times.Once);
|
||||
_mockCoreApiWrapperDao.Verify(x => x.PostFundsToAccount(It.IsAny<List<FundsToAccountRequest>>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_UpdateResult_Null_Fail()
|
||||
{
|
||||
//Set Up Objects
|
||||
var listAccounts = new List<string>(){"1111111"};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetVipSavingsToFund()).ReturnsAsync(listAccounts);
|
||||
|
||||
List<BasicResponse>? basicResponseList = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.AddFundsToVipSavingsAccounts
|
||||
};
|
||||
var result = await _addFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetVipSavingsToFund(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_BasicResponse_Return_NotSuccessful_Fail()
|
||||
{
|
||||
//Set Up Objects
|
||||
var listAccounts = new List<string>(){"1111111"};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetVipSavingsToFund()).ReturnsAsync(listAccounts);
|
||||
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = false,
|
||||
Errors = new List<string>() { "Error has occured" }
|
||||
};
|
||||
|
||||
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.AddFundsToVipSavingsAccounts
|
||||
};
|
||||
var result = await _addFundsToVipSavingsAccountsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetVipSavingsToFund(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Once);
|
||||
}
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
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.CoreSoapRequests;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class CloseCustodialVruAgreementsServiceTest
|
||||
{
|
||||
private CloseCustodialVruAgreementsService _closeCustodialVruAgreementsService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_closeCustodialVruAgreementsService = new CloseCustodialVruAgreementsService(_mockCoreApiWrapperService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success()
|
||||
{
|
||||
//Set Up GetActiveCustodialVruCardAgreementAgreePersons
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "11",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialVruCardAgreementAgreePersons()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _closeCustodialVruAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialVruCardAgreementAgreePersons(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_AgreePersons_Null_Fail()
|
||||
{
|
||||
//Set Up GetActiveCustodialVruCardAgreementAgreePersons
|
||||
List<AgreePerson> testAgreePersons = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialVruCardAgreementAgreePersons()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _closeCustodialVruAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialVruCardAgreementAgreePersons(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_UpdateResult_Null_Fail()
|
||||
{
|
||||
//Set Up GetActiveCustodialVruCardAgreementAgreePersons
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "11",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialVruCardAgreementAgreePersons()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
BasicResponse? basicResponse = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _closeCustodialVruAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialVruCardAgreementAgreePersons(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_BasicResponse_Return_NotSuccessful_Fail()
|
||||
{
|
||||
//Set Up GetActiveCustodialVruCardAgreementAgreePersons
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "11",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialVruCardAgreementAgreePersons()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = false,
|
||||
Errors = new List<string>() { "Error has occured" }
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _closeCustodialVruAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialVruCardAgreementAgreePersons(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdatePersonAgreementDetailTypes(It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Once);
|
||||
}
|
||||
}
|
||||
+735
@@ -0,0 +1,735 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Enum;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessTypes;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class DeactivateCustodialEAgreementsServiceTest
|
||||
{
|
||||
private DeactivateCustodialEAgreementsService _deactivateCustodialEAgreementsService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_deactivateCustodialEAgreementsService = new DeactivateCustodialEAgreementsService(_mockCoreApiWrapperService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testUpdatedAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = false
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()))
|
||||
.ReturnsAsync(testUpdatedAccessType);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success_NoHyphenatedUserIds()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateRequest_PersonNumber_NotLong()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111e111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_CoreApiMessage_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
CoreApiMessage<IEnumerable<AccessChannelPerson>>? coreApiMessage = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_CoreApiMessage_MessageHeader_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
CoreMessageHeader? coreMessageHeader = null;
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_CoreApiMessage_MessageHeader_UpdateKey_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = null
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_CoreApiMessage_MessageBody_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
List<AccessChannelPerson>? testAccessChannelPersons = null;
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_AccessChannelPersonsToUpdate_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "TTT",
|
||||
IsActive = true
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(0, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_UpdatedAccessType_Null()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
AccessType? testUpdatedAccessType = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()))
|
||||
.ReturnsAsync(testUpdatedAccessType);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_SetUpAccessTypeUpdateReques_UpdatedAccessType_IsActive_True()
|
||||
{
|
||||
//Set Up GetActiveCustodialAgreePersonNumbers
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetActiveCustodialAgreePersonNumbers()).ReturnsAsync(testPersonNumbers);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testUpdatedAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()))
|
||||
.ReturnsAsync(testUpdatedAccessType);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var result = await _deactivateCustodialEAgreementsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleUpdateDeactivateCustodialEAgreement_Success()
|
||||
{
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testUpdatedAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = false
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()))
|
||||
.ReturnsAsync(testUpdatedAccessType);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var cleanUpResult = new DataCleanUpResult(testRequest, true, new List<string>());
|
||||
var result = await _deactivateCustodialEAgreementsService.HandleUpdateDeactivateCustodialEAgreement(cleanUpResult, "111111");
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SetUpAccessTypeUpdateRequest_Success()
|
||||
{
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var testAccessType = new AccessType()
|
||||
{
|
||||
Id = "WWW",
|
||||
IsActive = true,
|
||||
UserId = null
|
||||
};
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
Id = "2313213_1",
|
||||
ChannelNumber = 2313213,
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
testAccessType
|
||||
}
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
testAccessChannelPerson ,
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1C1",
|
||||
AccessTypes = new List<AccessType>()
|
||||
{
|
||||
new AccessType()
|
||||
{
|
||||
Id= "VRU",
|
||||
IsActive = true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.DeactivateCustodialEAgreements
|
||||
};
|
||||
var cleanUpResult = new DataCleanUpResult(testRequest, true, new List<string>());
|
||||
var result = await _deactivateCustodialEAgreementsService.SetUpAccessTypeUpdateRequest("111111");
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testAccessType, result.AccessType);
|
||||
Assert.AreEqual(12312312323123, result.UpdateKey);
|
||||
Assert.AreEqual("2313213_1", result.AccessChannelPersonId);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetActiveCustodialAgreePersonNumbers(), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>(),
|
||||
It.IsAny<List<string>>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessType(It.IsAny<AccessTypeUpdateRequest>()), Times.Never);
|
||||
}
|
||||
}
|
||||
+591
@@ -0,0 +1,591 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.MemberAgreements;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Enum;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class HyphenatedUserIdCleanUpServiceTest
|
||||
{
|
||||
private HyphenatedUserIdCleanUpService _hyphenatedUserIdCleanUpService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_hyphenatedUserIdCleanUpService = new HyphenatedUserIdCleanUpService(_mockCoreApiWrapperService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1C1"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()))
|
||||
.ReturnsAsync(testAccessChannelPerson);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success_NoHyphenatedUserIds()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_ExceptionThrown()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ThrowsAsync(new Exception("Oops"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_CoreApiMessage_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
CoreApiMessage<IEnumerable<AccessChannelPerson>>? coreApiMessage = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_CoreApiMessage_MessageHeader_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
CoreMessageHeader? coreMessageHeader = null;
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_CoreApiMessage_UpdateKey_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = null
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_CoreApiMessage_MessageBody_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
List<AccessChannelPerson>? testAccessChannelPersons = null;
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_DetermineAccessChannelPersonUpdateDetails_AccessChannelWithHypenateduserId_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "3-3"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_HandleUpdateOfHyphenatedUserId_UpdatedAccessChannelPerson_Null()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
AccessChannelPerson? testAccessChannelPerson = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()))
|
||||
.ReturnsAsync(testAccessChannelPerson);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Result_Fail_HandleUpdateOfHyphenatedUserId_UpdatedAccessChannelPerson_UserId_DoesNotMatch_NewUserId()
|
||||
{
|
||||
//Set Up GetAgreePersonsWithHyphenatedUserIds
|
||||
var testAgreePersons = new List<AgreePerson>()
|
||||
{
|
||||
new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAgreePersonsWithHyphenatedUserIds()).ReturnsAsync(testAgreePersons);
|
||||
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1B1"
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()))
|
||||
.ReturnsAsync(testAccessChannelPerson);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleUpdateOfHyphenatedUserId_Success()
|
||||
{
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId= "1-1"
|
||||
}
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1C1"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()))
|
||||
.ReturnsAsync(testAccessChannelPerson);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.HyphenatedUserId
|
||||
};
|
||||
var dataCleanUpResult = new DataCleanUpResult(testRequest, true, new List<string>());
|
||||
var testAgreePerson = new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.HandleUpdateOfHyphenatedUserId(dataCleanUpResult, testAgreePerson);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DetermineAccessChannelPersonUpdateDetails_Success()
|
||||
{
|
||||
//Set Up GetCoreApiMessageAccessChannelPersons
|
||||
var coreMessageHeader = new CoreMessageHeader()
|
||||
{
|
||||
UpdateKey = 12312312323123
|
||||
};
|
||||
|
||||
var accessChannelPersonResult = new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1"
|
||||
};
|
||||
var testAccessChannelPersons = new List<AccessChannelPerson>()
|
||||
{
|
||||
new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "2312312312"
|
||||
},
|
||||
accessChannelPersonResult
|
||||
};
|
||||
var coreApiMessage = new CoreApiMessage<IEnumerable<AccessChannelPerson>>(coreMessageHeader, testAccessChannelPersons);
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()))
|
||||
.ReturnsAsync(coreApiMessage);
|
||||
|
||||
//Set Up UpdateAccessChannelPersons
|
||||
var testAccessChannelPerson = new AccessChannelPerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1C1"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()))
|
||||
.ReturnsAsync(testAccessChannelPerson);
|
||||
|
||||
var testAgreePerson = new AgreePerson()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserId = "1-1",
|
||||
AgreeNumber = 1
|
||||
};
|
||||
var result = await _hyphenatedUserIdCleanUpService.DetermineAccessChannelPersonUpdateDetails(testAgreePerson);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(12312312323123, result.updateKey);
|
||||
Assert.AreEqual(accessChannelPersonResult, result.accessChannelPerson);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetAgreePersonsWithHyphenatedUserIds(), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.GetCoreApiMessageAccessChannelPersons(It.IsAny<AccessChannelPersonsByPersonRequest>()), Times.Once);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccessChannelPersons(It.IsAny<AccessChannelPerson>(), It.IsAny<long>()), Times.Never);
|
||||
}
|
||||
}
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
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.Transaction;
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class MaskTransactionExternalDescriptionWithSsnServiceTest
|
||||
{
|
||||
private MaskTransactionExternalDescriptionWithSsnService _maskTransactionExternalDescriptionWithSsnService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_maskTransactionExternalDescriptionWithSsnService = new MaskTransactionExternalDescriptionWithSsnService(_mockCoreApiWrapperService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Success()
|
||||
{
|
||||
//Set Up
|
||||
var testExternalDescriptions = new List<ExternalDescription>()
|
||||
{
|
||||
new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = "State of Wisc - SSI 44444444444 *0000000000*333664444*Tester Test *120422\\"
|
||||
},
|
||||
new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = "State of Wisc - SSI 555555555555 *111111111*444775555*TesterB TestB *120422\\"
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetTransactionsExternalDescriptionsWithSsn())
|
||||
.ReturnsAsync(testExternalDescriptions);
|
||||
|
||||
var testBasicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateTransactionsExternalDescriptions(It.IsAny<ExternalDescription>()))
|
||||
.ReturnsAsync(testBasicResponse);
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.CleanUp(testDataCleanUpRequest);
|
||||
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(0, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_BadSsns()
|
||||
{
|
||||
//Set Up
|
||||
var testExternalDescriptions = new List<ExternalDescription>()
|
||||
{
|
||||
new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = "State of Wisc - SSI 44444444444 *0000000000*33364444*Tester Test *120422\\"
|
||||
},
|
||||
new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = "State of Wisc - SSI 555555555555 *111111111*4447755555*TesterB TestB *120422\\"
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetTransactionsExternalDescriptionsWithSsn())
|
||||
.ReturnsAsync(testExternalDescriptions);
|
||||
|
||||
var testBasicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateTransactionsExternalDescriptions(It.IsAny<ExternalDescription>()))
|
||||
.ReturnsAsync(testBasicResponse);
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.CleanUp(testDataCleanUpRequest);
|
||||
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(2, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUp_Fail_ExernalDescriptionsNull()
|
||||
{
|
||||
//Set Up
|
||||
List<ExternalDescription> testExternalDescriptions = null;
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetTransactionsExternalDescriptionsWithSsn())
|
||||
.ReturnsAsync(testExternalDescriptions);
|
||||
|
||||
var testBasicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateTransactionsExternalDescriptions(It.IsAny<ExternalDescription>()))
|
||||
.ReturnsAsync(testBasicResponse);
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.CleanUp(testDataCleanUpRequest);
|
||||
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleMaskingTransactionExternalDescriptionWithSsn_Success()
|
||||
{
|
||||
//Set Up
|
||||
var testBasicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateTransactionsExternalDescriptions(It.IsAny<ExternalDescription>()))
|
||||
.ReturnsAsync(testBasicResponse);
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
var testCleanUpResult = new DataCleanUpResult(testDataCleanUpRequest, true, new List<string>());
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *0000000000*333664444*Tester Test *120422\\";
|
||||
var testExternalDescription = new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = descptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.HandleMaskingTransactionExternalDescriptionWithSsn(testCleanUpResult, testExternalDescription);
|
||||
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.AreEqual(0, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleMaskingTransactionExternalDescriptionWithSsn_BasicResponseReturnedFail()
|
||||
{
|
||||
//Set Up
|
||||
var testBasicResponse = new BasicResponse()
|
||||
{
|
||||
Success = false,
|
||||
Errors = new List<string>()
|
||||
{
|
||||
"Failure"
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateTransactionsExternalDescriptions(It.IsAny<ExternalDescription>()))
|
||||
.ReturnsAsync(testBasicResponse);
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
var testCleanUpResult = new DataCleanUpResult(testDataCleanUpRequest, true, new List<string>());
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *0000000000*333664444*Tester Test *120422\\";
|
||||
var testExternalDescription = new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = descptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.HandleMaskingTransactionExternalDescriptionWithSsn(testCleanUpResult, testExternalDescription);
|
||||
|
||||
Assert.IsFalse (result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleMaskingTransactionExternalDescriptionWithSsn_Fail_CoreUpdateReturnWasnull()
|
||||
{
|
||||
|
||||
var testDataCleanUpRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.MaskTransactionExternalDescriptionWithSsn
|
||||
};
|
||||
var testCleanUpResult = new DataCleanUpResult(testDataCleanUpRequest, true, new List<string>());
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *0000000000*333664444*Tester Test *120422\\";
|
||||
var testExternalDescription = new ExternalDescription()
|
||||
{
|
||||
ExternalDescriptionNumber = 1,
|
||||
ExternalDescriptionText = descptionWithSsn
|
||||
};
|
||||
|
||||
var result = await _maskTransactionExternalDescriptionWithSsnService
|
||||
.HandleMaskingTransactionExternalDescriptionWithSsn(testCleanUpResult, testExternalDescription);
|
||||
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaskSsn_Success()
|
||||
{
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *0000000000*333664444*Tester Test *120422\\";
|
||||
var result = _maskTransactionExternalDescriptionWithSsnService.MaskSsn(descptionWithSsn);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("State of Wisc - SSI 44444444444 *0000000000*XXXXX4444*Tester Test *120422\\", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaskSsn_ThrowException_DoesNotMeetPattern()
|
||||
{
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *333664444*Tester Test *120422\\";
|
||||
|
||||
var ex = Assert.Throws<Exception>(() => _maskTransactionExternalDescriptionWithSsnService.MaskSsn(descptionWithSsn));
|
||||
Assert.That(ex.Message, Is.EqualTo("Transaction External Description does not meet the pattern. Was expecting 5 sections split by * but there were 4 sections."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MaskSsn_ThrowException_SsnPatternContainedHyphens_Length_11()
|
||||
{
|
||||
var descptionWithSsn = "State of Wisc - SSI 44444444444 *0000000000*333-66-4444*Tester Test *120422\\";
|
||||
|
||||
var ex = Assert.Throws<Exception>(() => _maskTransactionExternalDescriptionWithSsnService.MaskSsn(descptionWithSsn));
|
||||
Assert.That(ex.Message, Is.EqualTo("The SSN pulled from the Transaction External Description does not meet the pattern." +
|
||||
$"Was expecting SSN to be a lenght of 9 but it was 11."));
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
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 Newtonsoft.Json;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class UpdateAccountCreditReportTypeServiceTest
|
||||
{
|
||||
private UpdateAccountCreditReportTypeService _updateAccountCreditReportTypeService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_updateAccountCreditReportTypeService = new UpdateAccountCreditReportTypeService(_mockCoreApiWrapperService.Object, _mockFileOperationsService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAccountCreditReportTypeService_Success()
|
||||
{
|
||||
var creditReportRequest = new CreditReportTypeRequest()
|
||||
{
|
||||
SourcePath = "\\\test\\test.csv"
|
||||
};
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountCreditReportType,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(creditReportRequest)
|
||||
};
|
||||
|
||||
string strFileData = "AccountNumber,BorrowerName,Balance" + "\r\n" +
|
||||
"111,SOFIA ADAMS,100.50";
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(creditReportRequest.SourcePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountCreditReportType(It.IsAny<long>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var result = await _updateAccountCreditReportTypeService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountCreditReportType(It.IsAny<long>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAccountCreditReportTypeService_Fail()
|
||||
{
|
||||
var creditReportRequest = new CreditReportTypeRequest()
|
||||
{
|
||||
SourcePath = "\\\test\\test.csv"
|
||||
};
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountCreditReportType,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(creditReportRequest)
|
||||
};
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(It.IsAny<string>())).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var result = await _updateAccountCreditReportTypeService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountCreditReportType(It.IsAny<long>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
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.Api.Internal.DataCleanUp.Configuration;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class UpdateAccountGroupForAnalysisServiceTest
|
||||
{
|
||||
private UpdateAccountGroupForAnalysisService _updateAccountGroupForAnalysisService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<ICoreApiWrapperDao> _mockCoreApiWrapperDao;
|
||||
private DataCleanupDefaults _dataCleanUpDefaults;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
_dataCleanUpDefaults = new DataCleanupDefaults();
|
||||
|
||||
_mockCoreApiWrapperDao = new Mock<ICoreApiWrapperDao>();
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_updateAccountGroupForAnalysisService = new UpdateAccountGroupForAnalysisService(_mockCoreApiWrapperService.Object, _dataCleanUpDefaults);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAccountGroups_Success()
|
||||
{
|
||||
var listAccounts = new List<string>() { "23" };
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetGroupUpdateForAnalysisAccountNumbers()).ReturnsAsync(listAccounts);
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountGroupForAnalysis
|
||||
};
|
||||
var result = await _updateAccountGroupForAnalysisService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()), Times.Once);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAccountGroups_Fail()
|
||||
{
|
||||
//Set Up Object
|
||||
var basicResponse = new BasicResponse();
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountGroupForAnalysis(It.IsAny<string>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountGroupForAnalysis
|
||||
};
|
||||
var result = await _updateAccountGroupForAnalysisService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.AreEqual(0, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperDao.Verify(x => x.UpdateAccountGroupForAnalysis(It.IsAny<AccountAnalysisGroupMaintenanceRequest>()), Times.Never);
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Api.Internal.DataCleanUp.Models;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreResponses;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Properties;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Enum;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services
|
||||
{
|
||||
public class UpdateAccountPmiCancelServiceTest
|
||||
{
|
||||
private UpdateAccountPmiCancelService _updateAccountPmiCancelService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
private DataCleanupDefaults _dataCleanUpDefaults;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dataCleanUpDefaults = new DataCleanupDefaults()
|
||||
{
|
||||
PmiCancelSourcePath = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\PMICancel\\PMI Cancel.csv",
|
||||
PmiCancelSummaryPath = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\PMICancel\\"
|
||||
};
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_updateAccountPmiCancelService = new UpdateAccountPmiCancelService(_mockCoreApiWrapperService.Object, _mockFileOperationsService.Object, _dataCleanUpDefaults);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPropertyUserField_Fail()
|
||||
{
|
||||
//Set Up Object
|
||||
var basicResponse = new BasicResponse();
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountPmiCancel(It.IsAny<PmiCancel>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountPmiCancel
|
||||
};
|
||||
var result = await _updateAccountPmiCancelService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPropertyUserField_Success()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.PmiCancelSourcePath;
|
||||
string data = "Test";
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath))
|
||||
.ReturnsAsync(data);
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAccountPmiCancel(It.IsAny<PmiCancel>()))
|
||||
.ReturnsAsync(basicResponse);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateAccountPmiCancel
|
||||
};
|
||||
var result = await _updateAccountPmiCancelService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.Models;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.Services.Emailers;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
|
||||
using LCU.Library.Internal.DataCleanUpModel.Models;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class UpdateFannieMaeMortgageServiceTest
|
||||
{
|
||||
private UpdateFannieMaeMortgageService _updateFannieMaeMortgageService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
private FannieMaeConfiguration _fannieMaeConfiguration;
|
||||
private DataCleanUpConfiguration _dataCleanUpConfiguration;
|
||||
private Mock<INotificationsApiService> _mockEmailService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dataCleanUpConfiguration = new DataCleanUpConfiguration()
|
||||
{
|
||||
TimeZone = "America/Chicago"
|
||||
};
|
||||
|
||||
_fannieMaeConfiguration = new FannieMaeConfiguration()
|
||||
{
|
||||
ErrorFileDefaultName = "FannieMaeErrorRecord",
|
||||
SummaryEmailSubject = "FannieMaeSummaryEmail",
|
||||
PoolDateUserFieldId = "PLDT",
|
||||
PoolNbrUserFieldId = "PLNB",
|
||||
FileDateFormat = "M/d/yyyy",
|
||||
DnaDateFormat = "yyyy-MM-dd"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_mockEmailService = new Mock<INotificationsApiService>();
|
||||
_updateFannieMaeMortgageService = new UpdateFannieMaeMortgageService(_mockCoreApiWrapperService.Object,
|
||||
_mockFileOperationsService.Object,
|
||||
_fannieMaeConfiguration,
|
||||
_dataCleanUpConfiguration,
|
||||
_mockEmailService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProcessFannieMaeRecordPoolDate_Ok()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResult = new FannieMaeUpdateResult(request.Filename);
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1,
|
||||
ServicerLoanNumber = 99998888888800000,
|
||||
PoolIssueDate = "6/1/2023"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
updateResult.UpdateList = fannieMaeList;
|
||||
|
||||
var accountUserValuesList = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
AccountNumber = 99998888888800000,
|
||||
Value = "6/1/2023",
|
||||
UserFieldCode = _fannieMaeConfiguration.PoolDateUserFieldId
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddAccountUserField(It.IsAny<long>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(accountUserValuesList).Verifiable();
|
||||
|
||||
var result = await _updateFannieMaeMortgageService.ProcessFannieMaeRecord(fannieMaeMortgage1, updateResult, _fannieMaeConfiguration.PoolDateUserFieldId, fannieMaeMortgage1.PoolIssueDate);
|
||||
|
||||
Assert.AreEqual(0, result.ErrorList.Count());
|
||||
Assert.AreEqual(2, result.UpdateList.Count());
|
||||
Assert.AreEqual(fannieMaeMortgage1.ServicerLoanNumber, accountUserValuesList[0].AccountNumber);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProcessFannieMaeRecordForPoolDate_Error()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResult = new FannieMaeUpdateResult(request.Filename);
|
||||
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1,
|
||||
ServicerLoanNumber = 99998877778800000,
|
||||
PoolIssueDate = "6/1/2023"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
updateResult.UpdateList = fannieMaeList;
|
||||
|
||||
var result = _updateFannieMaeMortgageService.ProcessFannieMaeRecord(fannieMaeMortgage1, updateResult, _fannieMaeConfiguration.PoolDateUserFieldId, fannieMaeMortgage1.PoolIssueDate);
|
||||
|
||||
Assert.AreEqual(1, result.Result.ErrorList.Count());
|
||||
Assert.AreEqual("Fannie Mae Loan Record Failed: 99998877778800000", result.Result.ErrorList[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProcessFannieMaeRecordPoolNumber_Ok()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResult = new FannieMaeUpdateResult(request.Filename);
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1,
|
||||
ServicerLoanNumber = 99998888888800000,
|
||||
PoolNumber = "TEST1234"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
updateResult.UpdateList = fannieMaeList;
|
||||
|
||||
var accountUserValuesList = new List<AccountUserField>()
|
||||
{
|
||||
new AccountUserField()
|
||||
{
|
||||
AccountNumber = 99998888888800000,
|
||||
Value = "TEST1234",
|
||||
UserFieldCode = _fannieMaeConfiguration.PoolNbrUserFieldId
|
||||
}
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddAccountUserField(It.IsAny<long>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(accountUserValuesList).Verifiable();
|
||||
|
||||
var result = await _updateFannieMaeMortgageService.ProcessFannieMaeRecord(fannieMaeMortgage1, updateResult, _fannieMaeConfiguration.PoolNbrUserFieldId, fannieMaeMortgage1.PoolNumber);
|
||||
|
||||
Assert.AreEqual(0, result.ErrorList.Count());
|
||||
Assert.AreEqual(2, result.UpdateList.Count());
|
||||
Assert.AreEqual(fannieMaeMortgage1.ServicerLoanNumber, accountUserValuesList[0].AccountNumber);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProcessFannieMaeRecordForPoolNumber_Error()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResult = new FannieMaeUpdateResult(request.Filename);
|
||||
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1288,
|
||||
ServicerLoanNumber = 99998566800000,
|
||||
PoolNumber = "TEST1234"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
updateResult.UpdateList = fannieMaeList;
|
||||
|
||||
var result = _updateFannieMaeMortgageService.ProcessFannieMaeRecord(fannieMaeMortgage1, updateResult, _fannieMaeConfiguration.PoolNbrUserFieldId, fannieMaeMortgage1.PoolNumber);
|
||||
|
||||
Assert.AreEqual(1, result.Result.ErrorList.Count());
|
||||
Assert.AreEqual("Fannie Mae Loan Record Failed: 99998566800000", result.Result.ErrorList[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildTotalBatchSummary_Ok_UpdatesErrors()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResults = new List<FannieMaeUpdateResult>();
|
||||
var resultOne = new FannieMaeUpdateResult(request.Filename);
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"errorThree"
|
||||
};
|
||||
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1,
|
||||
PoolIssueDate = "6/1/2023",
|
||||
PoolNumber = "XXXZ23443"
|
||||
};
|
||||
var fannieMaeMortgage2 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 2,
|
||||
PoolIssueDate = "6/1/2023",
|
||||
PoolNumber = "DDDZ23443"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
fannieMaeList.Add(fannieMaeMortgage2);
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = fannieMaeList;
|
||||
resultOne.TotalRecordsFound = 5;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
|
||||
var result = _updateFannieMaeMortgageService.BuildTotalBatchSummary(updateResults, true);
|
||||
|
||||
Assert.AreEqual(5, result.TotalRecordsFound);
|
||||
Assert.AreEqual(3, result.TotalErrorRecords);
|
||||
Assert.AreEqual(true, result.ErrorFileCreated);
|
||||
Assert.AreEqual(2, result.TotalRecordsUpdated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildTotalBatchSummary_Ok_UpdatesNoErrors()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResults = new List<FannieMaeUpdateResult>();
|
||||
var resultOne = new FannieMaeUpdateResult(request.Filename);
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
var fannieMaeMortgage1 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 1,
|
||||
PoolIssueDate = "6/1/2023",
|
||||
PoolNumber = "XXXZ23443"
|
||||
};
|
||||
var fannieMaeMortgage2 = new FannieMaeMortgage()
|
||||
{
|
||||
FannieMaeLoanNumber = 2,
|
||||
PoolIssueDate = "6/1/2023",
|
||||
PoolNumber = "DDDZ23443"
|
||||
};
|
||||
|
||||
fannieMaeList.Add(fannieMaeMortgage1);
|
||||
fannieMaeList.Add(fannieMaeMortgage2);
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = fannieMaeList;
|
||||
resultOne.TotalRecordsFound = 2;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
|
||||
var result = _updateFannieMaeMortgageService.BuildTotalBatchSummary(updateResults, false);
|
||||
|
||||
Assert.AreEqual(2, result.TotalRecordsFound);
|
||||
Assert.AreEqual(0, result.TotalErrorRecords);
|
||||
Assert.AreEqual(false, result.ErrorFileCreated);
|
||||
Assert.AreEqual(2, result.TotalRecordsUpdated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildTotalBatchSummary_Ok_NoUpdatesNoErrors()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResults = new List<FannieMaeUpdateResult>();
|
||||
var resultOne = new FannieMaeUpdateResult(request.Filename);
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var fannieMaeList = new List<FannieMaeMortgage>();
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = fannieMaeList;
|
||||
resultOne.TotalRecordsFound = 0;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
|
||||
var result = _updateFannieMaeMortgageService.BuildTotalBatchSummary(updateResults, false);
|
||||
|
||||
Assert.AreEqual(0, result.TotalRecordsFound);
|
||||
Assert.AreEqual(0, result.TotalErrorRecords);
|
||||
Assert.AreEqual(false, result.ErrorFileCreated);
|
||||
Assert.AreEqual(0, result.TotalRecordsUpdated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddStringToErrorList_Ok()
|
||||
{
|
||||
var request = new FannieMaeMortgageRequest()
|
||||
{
|
||||
Filename = "TestFile"
|
||||
};
|
||||
|
||||
var updateResult = new FannieMaeUpdateResult(request.Filename);
|
||||
updateResult.ErrorList = new List<string>();
|
||||
|
||||
var fannieMaeRecord = new FannieMaeMortgage()
|
||||
{
|
||||
ServicerLoanNumber = 1,
|
||||
PoolIssueDate = "6/1/2023",
|
||||
PoolNumber = "TEST1234"
|
||||
};
|
||||
|
||||
var expectedError = "1|TEST1234|6/1/2023|Unit test error message\n";
|
||||
updateResult.AddStringToErrorList(fannieMaeRecord, "Unit test error message");
|
||||
|
||||
Assert.AreEqual(1, updateResult.ErrorList.Count);
|
||||
Assert.AreEqual(expectedError, updateResult.ErrorList.FirstOrDefault());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+454
@@ -0,0 +1,454 @@
|
||||
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;
|
||||
|
||||
public class UpdateMissingSavingsAccountServiceTest
|
||||
{
|
||||
private UpdateMissingBatchSavingsService _updateMissingBatchSavingsService;
|
||||
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,
|
||||
BatchSavingsSourcePath = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\BatchSavings\\MissingBatchSavings.csv",
|
||||
BatchSavingsSummarySourcePath = "\\\\zeus\\DataIntegrationsQA\\DataCleanUp\\BatchSavings\\"
|
||||
};
|
||||
|
||||
_savingsDefaults = new SavingsMissingRequirementsDefaults()
|
||||
{
|
||||
FundsToAccountDefaults = new FundsToAccountDefaults()
|
||||
{
|
||||
|
||||
},
|
||||
SavingDefaults = new SavingsDefaults()
|
||||
{
|
||||
BankOrganizationNumber = "1",
|
||||
BatchAccountDescription = "test",
|
||||
CurrentAccountStatusCode = "Z",
|
||||
CurrentMinorAccountTypeCode = "X",
|
||||
DeliveryMethodCode = "DD",
|
||||
OwnershipCode = "OW",
|
||||
IsTaxReportedForOwner = true,
|
||||
IsTaxReportedForSigner = true,
|
||||
IsValid = true,
|
||||
MajorAccountTypeCode = "MM"
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_updateMissingBatchSavingsService = new UpdateMissingBatchSavingsService(_mockCoreApiWrapperService.Object, _mockFileOperationsService.Object, _dataCleanUpDefaults, _savingsDefaults);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonMissingBatchSavingsUpdate_Success()
|
||||
{
|
||||
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"111,SOFIA,Test,Person,,0,,0,1123,0,N,444 S Zero Pl, ,NOWHERE,WI,55555,Y";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new CreatedAccountResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BasicResponse = new BasicResponse { Errors = new List<string>(), Success = true }
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponse };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(response.AccountNumber.ToString(), 5))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonMissingBatchSavingsUpdate_Fail()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpOrganizationMissingBatchSavingsUpdate_Success()
|
||||
{
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"555,,,Organization,No Company,0,,0,1122,112826,N,Test Ave, ,TestTown,WI,55555,Y";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new CreatedAccountResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BasicResponse = new BasicResponse { Errors = new List<string>(), Success = true }
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Response
|
||||
var basicResponse = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponse };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(response.AccountNumber.ToString(), 5))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpOrganizationMissingBatchSavingsUpdate_Fail()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAddControllingPersonToOrganizationUpdate_Success()
|
||||
{
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"555,,,Organization,No Company,0,,0,1122,112826,Y,Test Ave, ,TestTown,WI,55555,N";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new BasicResponse()
|
||||
{
|
||||
Errors = new List<string>(),
|
||||
Success = true
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddControllingPersonOrganizationMaintenance(It.IsAny<OrganizationMaintenanceRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Response
|
||||
var acctresponse = new CreatedAccountResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BasicResponse = new BasicResponse { Errors = new List<string>(), Success = true }
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()))
|
||||
.ReturnsAsync(acctresponse);
|
||||
|
||||
//Set Up Response
|
||||
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.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpAddControllingPersonToOrganizationUpdate_Fail()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.AddControllingPersonOrganizationMaintenance(It.IsAny<OrganizationMaintenanceRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAndAddFundsForMissingBatchSavingsUpdate_Success()
|
||||
{
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"111,SOFIA,Test,Person,,0,,0,1123,0,N,444 S Zero Pl, ,NOWHERE,WI,55555,Y";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new CreatedAccountResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BasicResponse = new BasicResponse { Errors = new List<string>(), Success = true }
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Funds Response
|
||||
var basicResponseFunds = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponseFunds };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(response.AccountNumber.ToString(), 5))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAndAddFundsForMissingBatchSavingsUpdateWithBalance_Success()
|
||||
{
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"111,SOFIA,Test,Person,,1,223344,1.25,1123,0,N,444 S Zero Pl, ,NOWHERE,WI,55555,Y";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Funds Response
|
||||
var basicResponseFunds = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponseFunds };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount("223344", 3.75))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.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.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAndAddFundsForMissingBatchSavingsUpdate_Fail()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreatePersonAccount(It.IsAny<CreatePersonAccountRequest>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpOrganizationAndAddFundsForMissingBatchSavingsUpdate_Success()
|
||||
{
|
||||
string strFileData = "CUSTOMERNUMBER,FIRSTNAME,LASTNAME,CUSTOMERTYPE,ORGANIZATIONNAME,CORESAVINGSCOUNT,SAVINGSACCOUNTNUMBER,SAVINGSACCOUNTBALANCE,BRANCHCODE,CONTROLPERSON,ControlPersonNeeded,CustomerAddress1,CustomerAddress2,CustomerCity,CustomerState,CustomerZip,ControlPersonAssigned" + "\r\n" +
|
||||
"555,,,Organization,No Company,0,,0,1122,112826,N,Test Ave, ,TestTown,WI,55555,Y";
|
||||
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ReturnsAsync(strFileData);
|
||||
|
||||
//Set Up Response
|
||||
var response = new CreatedAccountResponse()
|
||||
{
|
||||
AccountNumber = 1,
|
||||
BasicResponse = new BasicResponse { Errors = new List<string>(), Success = true }
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()))
|
||||
.ReturnsAsync(response);
|
||||
|
||||
//Set Up Funds Response
|
||||
var basicResponseFunds = new BasicResponse()
|
||||
{
|
||||
Success = true,
|
||||
Errors = new List<string>()
|
||||
};
|
||||
|
||||
var basicResponseList = new List<BasicResponse>() { basicResponseFunds };
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()))
|
||||
.ReturnsAsync(basicResponseList);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpOrganizationAndAddFundsForMissingBatchSavingsUpdate_Fail()
|
||||
{
|
||||
var testFilePath = _dataCleanUpDefaults.BatchSavingsSourcePath;
|
||||
_mockFileOperationsService.Setup(x => x.GetContentData(testFilePath)).ThrowsAsync(new Exception("Nope"));
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdateMissingBatchSavings
|
||||
};
|
||||
|
||||
var result = await _updateMissingBatchSavingsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsFalse(result.Successful);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count());
|
||||
_mockCoreApiWrapperService.Verify(x => x.CreateOrganizationAccount(It.IsAny<CreateOrganizationAccountRequest>()), Times.Never);
|
||||
_mockCoreApiWrapperService.Verify(x => x.PostFundsToAccount(It.IsAny<string>(), It.IsAny<double>()), Times.Never);
|
||||
}
|
||||
|
||||
}
|
||||
+586
@@ -0,0 +1,586 @@
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Api.Internal.DataCleanUp.DataAccess;
|
||||
using LCU.Api.Internal.DataCleanUp.Models.ParserModels;
|
||||
using LCU.Api.Internal.DataCleanUp.Services;
|
||||
using LCU.Api.Internal.DataCleanUp.Services.Emailers;
|
||||
using LCU.Api.Internal.DataCleanUp.Services.Validation;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.PostalAddresses;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class UpdateNcoaProcessServiceTest
|
||||
{
|
||||
private UpdateNcoaProcessService _updateNcoaProcessService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
private NcoaConfiguration _ncoaConfiguration;
|
||||
private DataCleanUpConfiguration _dataCleanUpConfiguration;
|
||||
private INcoaValidationService _ncoaValidationService;
|
||||
private Mock<INotificationsApiService> _mockEmailService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dataCleanUpConfiguration = new DataCleanUpConfiguration()
|
||||
{
|
||||
TimeZone = "America/Chicago"
|
||||
};
|
||||
|
||||
_ncoaConfiguration = new NcoaConfiguration()
|
||||
{
|
||||
PrimaryAddressLabel = "PRI",
|
||||
StreetTypeLabel = "ST",
|
||||
UrlBase = "/Persons/{personNumber}/PostalAddresses/PRI",
|
||||
UsaLabel = "USA",
|
||||
PoBoxLabel = "PO BOX",
|
||||
PoBoxAddressTypeLabel = "POBN",
|
||||
ErrorFileDefaultName = "NCOAErrorRecord",
|
||||
PersonNumberLabel = "{personNumber}"
|
||||
};
|
||||
|
||||
_ncoaValidationService = new NcoaValidationService();
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_mockEmailService = new Mock<INotificationsApiService>();
|
||||
_updateNcoaProcessService = new UpdateNcoaProcessService(_mockCoreApiWrapperService.Object,
|
||||
_mockFileOperationsService.Object, _ncoaConfiguration,
|
||||
_dataCleanUpConfiguration, _ncoaValidationService,
|
||||
_mockEmailService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MapPersonAddressLine_NoPoBox()
|
||||
{
|
||||
//Arrange
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "Testerson's Testing",
|
||||
NewAddressLine = "New Address Line",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "-1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode"
|
||||
};
|
||||
|
||||
var currentAddress = new PersonPostalAddress()
|
||||
{
|
||||
AddressNumber = 456
|
||||
};
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.MapPersonAddrLine(98765, currentAddress, ncoaRecord);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(98765, result.PersonNumber);
|
||||
Assert.AreEqual("PRI", result.Id);
|
||||
Assert.AreEqual("PRI", result.AddressUseCode);
|
||||
Assert.AreEqual(456, result.AddressNumber);
|
||||
Assert.AreEqual("New Address Line", result.AddressLine1);
|
||||
Assert.AreEqual("ST", result.AddressLineTypeCode1);
|
||||
Assert.Null(result.AddressLine2);
|
||||
Assert.Null(result.AddressLineTypeCode2);
|
||||
Assert.Null(result.AddressLine3);
|
||||
Assert.Null(result.AddressLineTypeCode3);
|
||||
Assert.AreEqual("New Test City", result.CityName);
|
||||
Assert.AreEqual("WI", result.CountrySubdivisionCode);
|
||||
Assert.AreEqual("53022", result.PostalCode);
|
||||
Assert.AreEqual("1234", result.ZipPlus);
|
||||
Assert.AreEqual("USA", result.CountryCode);
|
||||
Assert.AreEqual("/Persons/98765/PostalAddresses/PRI", result.Url);
|
||||
Assert.False(result.IsPerformIRSCorrection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MapPersonAddressLine_PoBox()
|
||||
{
|
||||
//Arrange
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "Testerson's Testing",
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "-1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode"
|
||||
};
|
||||
|
||||
var currentAddress = new PersonPostalAddress()
|
||||
{
|
||||
AddressNumber = 456
|
||||
};
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.MapPersonAddrLine(98765, currentAddress, ncoaRecord);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(98765, result.PersonNumber);
|
||||
Assert.AreEqual("PRI", result.Id);
|
||||
Assert.AreEqual("PRI", result.AddressUseCode);
|
||||
Assert.AreEqual(456, result.AddressNumber);
|
||||
Assert.AreEqual("New Address Line PO BOX Test", result.AddressLine1);
|
||||
Assert.AreEqual("POBN", result.AddressLineTypeCode1);
|
||||
Assert.Null(result.AddressLine2);
|
||||
Assert.Null(result.AddressLineTypeCode2);
|
||||
Assert.Null(result.AddressLine3);
|
||||
Assert.Null(result.AddressLineTypeCode3);
|
||||
Assert.AreEqual("New Test City", result.CityName);
|
||||
Assert.AreEqual("WI", result.CountrySubdivisionCode);
|
||||
Assert.AreEqual("53022", result.PostalCode);
|
||||
Assert.AreEqual("1234", result.ZipPlus);
|
||||
Assert.AreEqual("USA", result.CountryCode);
|
||||
Assert.AreEqual("/Persons/98765/PostalAddresses/PRI", result.Url);
|
||||
Assert.False(result.IsPerformIRSCorrection);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CheckForBoBoxAddressLineType_NoPoBox()
|
||||
{
|
||||
//Arrange
|
||||
var personAddrLine = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "Negative Test",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.CheckForPoBoxAddressLineType(personAddrLine);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Negative Test", result.AddressLine1);
|
||||
Assert.AreEqual("ST", result.AddressLineTypeCode1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CheckForBoBoxAddressLineType_PoBox()
|
||||
{
|
||||
//Arrange
|
||||
var personAddrLine = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "Positive Test PO BOX Something",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.CheckForPoBoxAddressLineType(personAddrLine);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Positive Test PO BOX Something", result.AddressLine1);
|
||||
Assert.AreEqual("POBN", result.AddressLineTypeCode1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateErrorrecord_NoPersonNumber()
|
||||
{
|
||||
// Arrange
|
||||
var updateResult = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "Testerson's Testing",
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode"
|
||||
};
|
||||
|
||||
var expectedErrorrecord = "202212|123456||Test E Testerson|1 Imaginary Lane|Apt 13|Additional Address Line|ReallyLongCityName|Wisconsin, 53186" +
|
||||
"|New Address Line PO BOX Test|New Test City|WI|53022|1234|This is a test error message\n";
|
||||
|
||||
//Act
|
||||
updateResult.AddStringToErrorList(ncoaRecord, "This is a test error message");
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(1, updateResult.ErrorList.Count);
|
||||
Assert.AreEqual(expectedErrorrecord, updateResult.ErrorList.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateErrorrecord_WithPersonNumber()
|
||||
{
|
||||
// Arrange
|
||||
var updateResult = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "Testerson's Testing",
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode"
|
||||
};
|
||||
|
||||
var expectedErrorrecord = "202212|123456|11111|Test E Testerson|1 Imaginary Lane|Apt 13|Additional Address Line|ReallyLongCityName|Wisconsin, 53186" +
|
||||
"|New Address Line PO BOX Test|New Test City|WI|53022|1234|This is a test error message\n";
|
||||
|
||||
//Act
|
||||
updateResult.AddStringToErrorList(ncoaRecord, "This is a test error message", "11111");
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(1, updateResult.ErrorList.Count);
|
||||
Assert.AreEqual(expectedErrorrecord, updateResult.ErrorList.FirstOrDefault());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ConvertToTitleCase_FromLower()
|
||||
{
|
||||
//Arrange
|
||||
var textToChange = "milwaukee";
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.ConvertToTitleCase(textToChange);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Milwaukee", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ConvertToTitleCase_TwoWordCity()
|
||||
{
|
||||
//Arrange
|
||||
var textToChange = "menomonee falls";
|
||||
|
||||
//Act
|
||||
var result = _updateNcoaProcessService.ConvertToTitleCase(textToChange);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual("Menomonee Falls", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BuildTotalBatchSummary_Ok_OneResult()
|
||||
{
|
||||
// Arrange
|
||||
var updateResults = new List<UpdateNcoaProcessService.NcoaUpdateResult>();
|
||||
var resultOne = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"ErrorThree"
|
||||
};
|
||||
var persAddrLineList = new List<PersonAddrLine>();
|
||||
var persAddrLineOne = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "1234 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
var persAddrLineTwo = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "5678 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
persAddrLineList.Add(persAddrLineOne);
|
||||
persAddrLineList.Add(persAddrLineTwo);
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = persAddrLineList;
|
||||
resultOne.TotalRecordsFound = 5;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.BuildTotalBatchSummary(updateResults, true);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(5, result.TotalRecordsFound);
|
||||
Assert.AreEqual(3, result.TotalErrorRecords);
|
||||
Assert.AreEqual(2, result.TotalRecordsUpdated);
|
||||
Assert.True(result.ErrorFileCreated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BuildTotalBatchSummary_Ok_MultipleResults()
|
||||
{
|
||||
// Arrange
|
||||
var updateResults = new List<UpdateNcoaProcessService.NcoaUpdateResult>();
|
||||
var resultOne = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"ErrorThree"
|
||||
};
|
||||
var persAddrLineListOne = new List<PersonAddrLine>();
|
||||
var persAddrLineOne = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "1234 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
var persAddrLineTwo = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "5678 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
persAddrLineListOne.Add(persAddrLineOne);
|
||||
persAddrLineListOne.Add(persAddrLineTwo);
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = persAddrLineListOne;
|
||||
resultOne.TotalRecordsFound = 5;
|
||||
|
||||
var resultTwo = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListTwo = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
};
|
||||
|
||||
var persAddrLineThree = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "Updated Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
|
||||
var persAddrLineListTwo = new List<PersonAddrLine>();
|
||||
persAddrLineListTwo.Add(persAddrLineThree);
|
||||
|
||||
resultTwo.ErrorList = errorListTwo;
|
||||
resultTwo.UpdateList = persAddrLineListTwo;
|
||||
resultTwo.TotalRecordsFound = 3;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
updateResults.Add(resultTwo);
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.BuildTotalBatchSummary(updateResults, false);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(8, result.TotalRecordsFound);
|
||||
Assert.AreEqual(5, result.TotalErrorRecords);
|
||||
Assert.AreEqual(3, result.TotalRecordsUpdated);
|
||||
Assert.False(result.ErrorFileCreated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BuildTotalBatchSummary_Ok_NoResults()
|
||||
{
|
||||
// Arrange
|
||||
var updateResults = new List<UpdateNcoaProcessService.NcoaUpdateResult>();
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.BuildTotalBatchSummary(updateResults, false);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(0, result.TotalRecordsFound);
|
||||
Assert.AreEqual(0, result.TotalErrorRecords);
|
||||
Assert.AreEqual(0, result.TotalRecordsUpdated);
|
||||
Assert.False(result.ErrorFileCreated);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateTotalBatchSummaryString_OneResult_WithLocation()
|
||||
{
|
||||
// Arrange
|
||||
var updateResults = new List<UpdateNcoaProcessService.NcoaUpdateResult>();
|
||||
var resultOne = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"ErrorThree"
|
||||
};
|
||||
var persAddrLineList = new List<PersonAddrLine>();
|
||||
var persAddrLineOne = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "1234 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
var persAddrLineTwo = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "5678 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
persAddrLineList.Add(persAddrLineOne);
|
||||
persAddrLineList.Add(persAddrLineTwo);
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = persAddrLineList;
|
||||
resultOne.TotalRecordsFound = 5;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
|
||||
var batchSummary = new UpdateNcoaProcessService.NcoaTotalBatchSummary(updateResults, true);
|
||||
batchSummary.TotalRecordsFound = 5;
|
||||
batchSummary.TotalErrorRecords = 3;
|
||||
batchSummary.TotalRecordsUpdated = 2;
|
||||
|
||||
var expectedResult = $"NCOA Update Total Batch Summary:<br><br>Total Files in Batch: 1<br><br>Total Records Received: " +
|
||||
$"5<br><br>Total Records Updated: 2<br><br>Total Error Records: " +
|
||||
$"3<br><br>Total Records Processed: 5<br><br>" +
|
||||
$"Error File Created: True<br><br>Error File Location: Test Location<br><br>";
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.CreateTotalBatchSummaryString(batchSummary, "Test Location");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateTotalBatchSummaryString_TwoResults_NoLocation()
|
||||
{
|
||||
// Arrange
|
||||
var updateResults = new List<UpdateNcoaProcessService.NcoaUpdateResult>();
|
||||
var resultOne = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"ErrorThree"
|
||||
};
|
||||
var persAddrLineList = new List<PersonAddrLine>();
|
||||
var persAddrLineOne = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "1234 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
var persAddrLineTwo = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "5678 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
persAddrLineList.Add(persAddrLineOne);
|
||||
persAddrLineList.Add(persAddrLineTwo);
|
||||
|
||||
var resultTwo = new UpdateNcoaProcessService.NcoaUpdateResult();
|
||||
var errorListTwo = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
};
|
||||
|
||||
var persAddrLineThree = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "Updated Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
|
||||
var persAddrLineListTwo = new List<PersonAddrLine>();
|
||||
persAddrLineListTwo.Add(persAddrLineThree);
|
||||
|
||||
resultTwo.ErrorList = errorListTwo;
|
||||
resultTwo.UpdateList = persAddrLineListTwo;
|
||||
resultTwo.TotalRecordsFound = 3;
|
||||
|
||||
resultOne.ErrorList = errorListOne;
|
||||
resultOne.UpdateList = persAddrLineList;
|
||||
resultOne.TotalRecordsFound = 5;
|
||||
|
||||
updateResults.Add(resultOne);
|
||||
updateResults.Add(resultTwo);
|
||||
|
||||
var batchSummary = new UpdateNcoaProcessService.NcoaTotalBatchSummary(updateResults, false);
|
||||
batchSummary.TotalRecordsFound = 8;
|
||||
batchSummary.TotalErrorRecords = 5;
|
||||
batchSummary.TotalRecordsUpdated = 3;
|
||||
|
||||
var expectedResult = $"NCOA Update Total Batch Summary:<br><br>Total Files in Batch: 2<br><br>Total Records Received: " +
|
||||
$"8<br><br>Total Records Updated: 3<br><br>Total Error Records: " +
|
||||
$"5<br><br>Total Records Processed: 8<br><br>" +
|
||||
$"Error File Created: False<br><br>";
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.CreateTotalBatchSummaryString(batchSummary, "Test Location");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task BuildFileUpdateSummary()
|
||||
{
|
||||
// Arrange
|
||||
var updateResult = new UpdateNcoaProcessService.NcoaUpdateResult("Test File Name");
|
||||
var errorListOne = new List<string>()
|
||||
{
|
||||
"errorOne",
|
||||
"errorTwo",
|
||||
"ErrorThree"
|
||||
};
|
||||
var persAddrLineList = new List<PersonAddrLine>();
|
||||
var persAddrLineOne = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "1234 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
var persAddrLineTwo = new PersonAddrLine()
|
||||
{
|
||||
AddressLine1 = "5678 Some Address",
|
||||
AddressLineTypeCode1 = "ST"
|
||||
};
|
||||
persAddrLineList.Add(persAddrLineOne);
|
||||
persAddrLineList.Add(persAddrLineTwo);
|
||||
|
||||
updateResult.ErrorList = errorListOne;
|
||||
updateResult.UpdateList = persAddrLineList;
|
||||
updateResult.TotalRecordsFound = 5;
|
||||
|
||||
var expectedResult = $"--------------<br><br>NCOA File In Batch Summary:<br><br>Filename: Test File Name" +
|
||||
$"<br><br>Total Records Received: 5<br><br>Total Records Updated: 2" +
|
||||
$"<br><br>Total Error Records: 3<br><br>Total Records Processed: " +
|
||||
$"5<br><br>";
|
||||
|
||||
// Act
|
||||
var result = _updateNcoaProcessService.BuildFileUpdateSummary(updateResult);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult, result);
|
||||
}
|
||||
}
|
||||
+539
@@ -0,0 +1,539 @@
|
||||
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.CoreRequests;
|
||||
using System;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Persons;
|
||||
using TimeZoneConverter;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services;
|
||||
|
||||
public class UpdatePersonForAtmHoldsServiceTest
|
||||
{
|
||||
private UpdatePersonForAtmHoldsService _updatePersonForAtmHoldsService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<ICoreApiWrapperDao> _mockCoreApiWrapperDao;
|
||||
private DataCleanupDefaults _dataCleanUpDefaults;
|
||||
private DataCleanUpConfiguration _dataCleanUpConfiguration;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dataCleanUpConfiguration = new DataCleanUpConfiguration()
|
||||
{
|
||||
TimeZone = "America/Chicago"
|
||||
};
|
||||
|
||||
_dataCleanUpDefaults = new DataCleanupDefaults()
|
||||
{
|
||||
MemberCheckHoldsUserFieldCode = "MBRH",
|
||||
MemberCheckHoldsDays = 29
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperDao = new Mock<ICoreApiWrapperDao>();
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_updatePersonForAtmHoldsService = new UpdatePersonForAtmHoldsService(_mockCoreApiWrapperService.Object, _dataCleanUpDefaults, _dataCleanUpConfiguration);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_Success()
|
||||
{
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = DateTime.Now,
|
||||
RecentClosedEffectiveDate = DateTime.Now
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int?>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
//Set Up Response
|
||||
var personUserField = new PersonUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
Value = "N"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(personUserField);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var result = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.UpdateAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()), Times.Once);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_Fail()
|
||||
{
|
||||
//Set Up Response
|
||||
var listPersonUserFields = new PersonUserField();
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.UpdateAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(listPersonUserFields);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds
|
||||
};
|
||||
var result = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperDao.Verify(x => x.UpdateAtmCheckHoldsForPersonNumbers(It.IsAny<PersonUserFieldRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldAdd_Success()
|
||||
{
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = false,
|
||||
OldestActiveEffectiveDate = DateTime.Now,
|
||||
RecentClosedEffectiveDate = DateTime.Now
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int?>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
//Set Up Response
|
||||
var personUserField = new PersonUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
Value = "Y"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(personUserField);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
var result = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldAdd_Fail()
|
||||
{
|
||||
//Set Up Response
|
||||
var listPersonUserFields = new PersonUserField();
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(listPersonUserFields);
|
||||
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds
|
||||
};
|
||||
var result = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.AreEqual(1, result.ResponseStack.Count);
|
||||
_mockCoreApiWrapperDao.Verify(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<PersonUserFieldRequest>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldAddFetchSize_Success()
|
||||
{
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = false,
|
||||
OldestActiveEffectiveDate = DateTime.Now,
|
||||
RecentClosedEffectiveDate = DateTime.Now
|
||||
},
|
||||
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 2,
|
||||
UserFieldExists = false,
|
||||
OldestActiveEffectiveDate = DateTime.Now,
|
||||
RecentClosedEffectiveDate = DateTime.Now
|
||||
},
|
||||
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 3,
|
||||
UserFieldExists = false,
|
||||
OldestActiveEffectiveDate = DateTime.Now,
|
||||
RecentClosedEffectiveDate = DateTime.Now
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int?>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
//Set Up Response
|
||||
var personUserField = new PersonUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
Value = "Y"
|
||||
};
|
||||
|
||||
_mockCoreApiWrapperService.Setup(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()))
|
||||
.ReturnsAsync(personUserField);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
var result = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testRequest, result.Request);
|
||||
Assert.IsTrue(result.Successful);
|
||||
Assert.IsEmpty(result.ResponseStack);
|
||||
_mockCoreApiWrapperService.Verify(x => x.AddAtmCheckHoldsForPersonNumbers(It.IsAny<int>(), It.IsAny<string>()), Times.Exactly(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_NoAccounts_YesValue_Success()
|
||||
{
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = null,
|
||||
RecentClosedEffectiveDate = null
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("Y"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_ActiveInValidClosedInValid_YesValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-29));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime oldestActiveDate = checkHoldDate.AddDays(1);
|
||||
DateTime newestClosedDate = checkHoldDate.AddDays(-1);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = oldestActiveDate, //older active account date, invalid check hold timeframe
|
||||
RecentClosedEffectiveDate = newestClosedDate, //newer closed account date, invalid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("Y"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_NoClosedInvalidActive_YesValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-28));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime oldestActiveDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = oldestActiveDate, //more recent active account date, valid check hold timeframe
|
||||
RecentClosedEffectiveDate = null // no closed account, invalid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("Y"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_NoActiveInvalidClosed_YesValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-30));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime recentClosedDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = null, // no active account, invalid check hold timeframe
|
||||
RecentClosedEffectiveDate = recentClosedDate, //oldest closed account date, invalid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("Y"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_NoActiveClosedValid_NoValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-28));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime recentClosedDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = null, //no active account date, invalid check hold timeframe
|
||||
RecentClosedEffectiveDate = recentClosedDate, //newer closed account date, valid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("N"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_NoClosedActiveValid_NoValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-29));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime oldestActiveDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = oldestActiveDate, //older active account date, valid check hold timeframe
|
||||
RecentClosedEffectiveDate = null, //no closed account date, invalid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("N"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_ActiveClosedValid_NoValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-29));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime oldestActiveDate = checkHoldDate.AddDays(0);
|
||||
DateTime newestClosedDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = oldestActiveDate, //older active account date, valid check hold timeframe
|
||||
RecentClosedEffectiveDate = newestClosedDate, //newer closed account date, valid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("N"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_ActiveInvalidClosedValid_NoValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-28));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime olderActiveDate = checkHoldDate.AddDays(28);
|
||||
DateTime recentClosedDate = checkHoldDate.AddDays(0);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = olderActiveDate, //more recent active account date, invalid check hold timeframe
|
||||
RecentClosedEffectiveDate = recentClosedDate, //newer closed account date, valid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("N"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CleanUpPersonAtmCheckHoldUpdate_ActiveValidClosedInValid_NoValue_Success()
|
||||
{
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo("America/Chicago");
|
||||
DateTime checkHoldDateToConvert = Convert.ToDateTime(DateTime.Now.AddDays(-29));
|
||||
var checkHoldDate = TimeZoneInfo.ConvertTime(checkHoldDateToConvert, assumedTimezone).Date;
|
||||
DateTime olderActiveDate = checkHoldDate.AddDays(29);
|
||||
DateTime recentClosedDate = checkHoldDate.AddDays(29);
|
||||
|
||||
var listPersonCheckHoldsUserFields = new List<PersonCheckHoldsUserField>()
|
||||
{
|
||||
new PersonCheckHoldsUserField()
|
||||
{
|
||||
PersonNumber = 1,
|
||||
UserFieldExists = true,
|
||||
OldestActiveEffectiveDate = olderActiveDate, //more recent active account date, valid check hold timeframe
|
||||
RecentClosedEffectiveDate = recentClosedDate, //newer closed account date, invalid check hold timeframe
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetAtmCheckHoldsForPersonNumbers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<int>())).ReturnsAsync(listPersonCheckHoldsUserFields);
|
||||
|
||||
var newCheckHoldRequest = new UpdatePersonForCheckHoldRequest();
|
||||
var testRequest = new DataCleanUpRequest()
|
||||
{
|
||||
CleanUpType = CleanUpTypes.UpdatePersonForCheckHolds,
|
||||
DataCleanUpPayload = JsonConvert.SerializeObject(newCheckHoldRequest)
|
||||
};
|
||||
|
||||
var dataCleanUpResult = await _updatePersonForAtmHoldsService.CleanUp(testRequest);
|
||||
var userValueResult = _updatePersonForAtmHoldsService.DeterminePersonUserFieldValue(listPersonCheckHoldsUserFields[0]);
|
||||
|
||||
Assert.NotNull(dataCleanUpResult);
|
||||
Assert.AreEqual(testRequest, dataCleanUpResult.Request);
|
||||
Assert.IsTrue(userValueResult.Equals("N"));
|
||||
}
|
||||
}
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
using LCU.Api.Internal.DataCleanUp.Models.ParserModels;
|
||||
using LCU.Api.Internal.DataCleanUp.Services.Validation;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.PostalAddresses;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Services.Validation;
|
||||
|
||||
public class NcoaValidationServiceTest
|
||||
{
|
||||
private readonly NcoaValidationService _ncoaValidationService;
|
||||
|
||||
public NcoaValidationServiceTest()
|
||||
{
|
||||
_ncoaValidationService = new NcoaValidationService();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsBusinessRecord_True()
|
||||
{
|
||||
// Arrange
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "Testerson's Testing",
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode",
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsBusinessRecord(ncoaRecord);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsBusinessRecord_False_Null()
|
||||
{
|
||||
// Arrange
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = null,
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode",
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsBusinessRecord(ncoaRecord);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsBusinessRecord_False_Empty()
|
||||
{
|
||||
// Arrange
|
||||
var ncoaRecord = new NcoaRecord()
|
||||
{
|
||||
UserId = "123456",
|
||||
NcoaType = "I",
|
||||
ChangeDate = "202212",
|
||||
PrimaryName = "Test E Testerson",
|
||||
CurrentAddressOne = "1 Imaginary Lane",
|
||||
CurrentAddressTwo = "Apt 13",
|
||||
CurrentAddressThree = "Additional Address Line",
|
||||
CurrentAddressFour = "ReallyLongCityName",
|
||||
CurrentAddressFive = "Wisconsin, 53186",
|
||||
SecondaryName = "Test Testerson",
|
||||
BusinessName = "",
|
||||
NewAddressLine = "New Address Line PO BOX Test",
|
||||
City = "New Test City",
|
||||
StateCode = "WI",
|
||||
ZipCode = "53022",
|
||||
ZipSuffix = "1234",
|
||||
UserIdTwo = "123456",
|
||||
StatementCode = "TestStatementCode",
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsBusinessRecord(ncoaRecord);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ParsePersonNumber_Ok()
|
||||
{
|
||||
// Arrange
|
||||
var agreement = new Agreement()
|
||||
{
|
||||
PersonNumber = 111
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.ParsePersonNumber(agreement);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(111, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ParsePersonNumber_FailParse()
|
||||
{
|
||||
// Arrange
|
||||
var agreement = new Agreement()
|
||||
{
|
||||
PersonNumber = 11111111111
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.ParsePersonNumber(agreement);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(-1, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ParsePersonNumber_NullAgreement()
|
||||
{
|
||||
// Arrange/Act
|
||||
var result = _ncoaValidationService.ParsePersonNumber(null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(-1, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddrUseCodeFound_Ok()
|
||||
{
|
||||
// Arrange
|
||||
var addressList = new List<PersonPostalAddress>();
|
||||
var address = new PersonPostalAddress()
|
||||
{
|
||||
AddressUseCode = "PRI",
|
||||
AddressNumber = 111
|
||||
};
|
||||
addressList.Add(address);
|
||||
addressList.AsReadOnly();
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddrUseCodeFound(addressList, "PRI");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(111, result.AddressNumber);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddrUseCodeFound_Null()
|
||||
{
|
||||
// Arrange
|
||||
var addressList = new List<PersonPostalAddress>();
|
||||
var address = new PersonPostalAddress()
|
||||
{
|
||||
AddressUseCode = "ALT",
|
||||
AddressNumber = 111
|
||||
};
|
||||
addressList.Add(address);
|
||||
addressList.AsReadOnly();
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddrUseCodeFound(addressList, "PRI");
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddrLineTooLong_Ok()
|
||||
{
|
||||
// Arrange
|
||||
string addrLine = "Short Address";
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddrLineTooLong(addrLine);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddrLineTooLong_TooLong()
|
||||
{
|
||||
// Arrange
|
||||
string addrLine = "This is a long addrLine that should be more than 40 characters and should fail validation";
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddrLineTooLong(addrLine);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AgreementHasOrgNumber_Ok()
|
||||
{
|
||||
// Arrange
|
||||
var agreement = new Agreement()
|
||||
{
|
||||
PersonNumber = 11111111111
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.AgreementHasOrgNumber(agreement);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AgreementHasOrgNumber_HasOrgNumber()
|
||||
{
|
||||
// Arrange
|
||||
var agreement = new Agreement()
|
||||
{
|
||||
PersonNumber = 11111111111,
|
||||
ByOrgNbr = 123456
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.AgreementHasOrgNumber(agreement);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsOnExlusionList_OnExclusionList()
|
||||
{
|
||||
// Arrange
|
||||
var exclusionList = new List<string>()
|
||||
{
|
||||
"12345",
|
||||
"6789",
|
||||
"2468"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsOnExclusionList(2468, exclusionList);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsOnExlusionList_NotOnExclusionList()
|
||||
{
|
||||
// Arrange
|
||||
var exclusionList = new List<string>()
|
||||
{
|
||||
"12345",
|
||||
"6789",
|
||||
"2468"
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsOnExclusionList(13579, exclusionList);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddressUpdatedRecently_UpdatedRecently()
|
||||
{
|
||||
// Arrange
|
||||
var personPostalAddress = new PersonPostalAddress()
|
||||
{
|
||||
LastMaintained = DateTime.Now.AddDays(-10)
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddressUpdatedRecently(personPostalAddress, -25, DateTime.Now.ToString());
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddressUpdatedRecently_UpdatedRecently_SameAsExclusionDays()
|
||||
{
|
||||
// Arrange
|
||||
var time = DateTime.Now;
|
||||
var personPostalAddress = new PersonPostalAddress()
|
||||
{
|
||||
LastMaintained = time.AddDays(-25)
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddressUpdatedRecently(personPostalAddress, -25, time.ToString());
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task IsAddressUpdatedRecently_NotUpdatedRecently()
|
||||
{
|
||||
// Arrange
|
||||
var personPostalAddress = new PersonPostalAddress()
|
||||
{
|
||||
LastMaintained = DateTime.Now.AddDays(-25)
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _ncoaValidationService.IsAddressUpdatedRecently(personPostalAddress, -10, DateTime.Now.ToString());
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using LCU.Api.Internal.DataCleanUp.Configuration;
|
||||
using LCU.Library.Internal.ApiSecurity.Enums;
|
||||
using LCU.Library.Internal.ApiSecurity.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.LcuHttpClient.Utilities;
|
||||
|
||||
namespace LCU.Api.Internal.DataCleanUpTest.Utilities;
|
||||
|
||||
public class HttpUtilitiesTest
|
||||
{
|
||||
|
||||
private const string ClientKeyValue = "DataCleanUp";
|
||||
private const string IncludesParameterKey = "includes";
|
||||
|
||||
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithInternalKey = new ApiSecurityConfiguration()
|
||||
{
|
||||
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
|
||||
ExternalApiKeySet = new Dictionary<string, string>(),
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
{
|
||||
{ ClientKeyValue, "some_guid-1234-5666" }
|
||||
}
|
||||
};
|
||||
|
||||
private readonly ApiSecurityConfiguration _apiSecurityConfigurationWithoutInternalKey = new ApiSecurityConfiguration()
|
||||
{
|
||||
ApiKeyAuthenticationFailureBehavior = ApiKeyAuthenticationFailureBehavior.Error,
|
||||
ExternalApiKeySet = new Dictionary<string, string>(),
|
||||
InternalApiKeySet = new Dictionary<string, string>()
|
||||
};
|
||||
|
||||
private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration = new CoreApiWrapperConfiguration()
|
||||
{
|
||||
CoreApiWrapperUrl = "https://localhost:44364",
|
||||
AccessChannelPersons = "/api/core/AccessChannelPersons",
|
||||
AccesschannelPersonWithIncludes = "/api/core/AccessChannelPersons/GetWithIncludes"
|
||||
};
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HttpUtilities_GetApiKeyHeaders_Success()
|
||||
{
|
||||
var result = HttpUtilities.GetApiKeyHeaders(ClientKeyValue,
|
||||
_apiSecurityConfigurationWithInternalKey.ExtractApiKey(ClientKeyValue, ApiKeySetName.InternalKeySet));
|
||||
|
||||
var modelValues = new Dictionary<string, string?>()
|
||||
{
|
||||
{"Client", ClientKeyValue },
|
||||
{"ApiKey", "some_guid-1234-5666" }
|
||||
};
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(modelValues, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HttpUtilities_BuildEndPointWithModelParams_Success()
|
||||
{
|
||||
var request = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
PersonNumber = 145,
|
||||
ActiveOnly = true,
|
||||
IncludeCards = false
|
||||
};
|
||||
|
||||
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccessChannelPersons}";
|
||||
|
||||
var result = HttpUtilities.BuildEndPointWithQueryParams(path, request);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons?PersonNumber=145&ActiveOnly=True&IncludeCards=False", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HttpUtilities_BuildEndPointWithDictionaryParams_Success()
|
||||
{
|
||||
var request = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
PersonNumber = 145,
|
||||
ActiveOnly = true,
|
||||
IncludeCards = false
|
||||
};
|
||||
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
|
||||
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccesschannelPersonWithIncludes}";
|
||||
var dictionaryOfParameters = HttpUtilities.BuildDictionaryValues(request);
|
||||
foreach (var includedString in testPersonNumbers)
|
||||
{
|
||||
dictionaryOfParameters.Add(IncludesParameterKey, includedString);
|
||||
}
|
||||
|
||||
var result = HttpUtilities.BuildEndPointWithQueryParams(path, dictionaryOfParameters);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons/GetWithIncludes?PersonNumber=145&ActiveOnly=True&IncludeCards=False&includes=111111", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HttpUtilities_BuildEndPointWithKeyValuePairModelListPropertyParams_Success()
|
||||
{
|
||||
var request = new AccountsByMajorMinorBranchAndStatusRequest()
|
||||
{
|
||||
MajorTypes = new List<string>() { "SAV"},
|
||||
MinorTypes = new List<string>() { "SV01", "BS01"},
|
||||
AccountStatuses = new List<string>() { "APPR"},
|
||||
BranchCodes = new List<long>() { 1310 }
|
||||
};
|
||||
|
||||
var testPersonNumbers = new List<string>()
|
||||
{
|
||||
"111111"
|
||||
};
|
||||
|
||||
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.GetAccountsByMajorMinorBranchAndStatus}";
|
||||
var keyValuePairs = HttpUtilities.BuildKeyValuePairs(request);
|
||||
|
||||
var result = HttpUtilities.BuildEndPointWithKeyValuePairs(path, keyValuePairs);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("https://localhost:44364?MajorTypes=SAV&MinorTypes=SV01&MinorTypes=BS01&AccountStatuses=APPR&BranchCodes=1310", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HttpUtilities_BuildEndPointWithKeyValuePairModelPropertyParams_Success()
|
||||
{
|
||||
|
||||
var request = new AccessChannelPersonsByPersonRequest()
|
||||
{
|
||||
PersonNumber = 145,
|
||||
ActiveOnly = true,
|
||||
IncludeCards = false
|
||||
};
|
||||
|
||||
|
||||
var path = $"{_coreApiWrapperConfiguration.CoreApiWrapperUrl}{_coreApiWrapperConfiguration.AccessChannelPersons}";
|
||||
var keyValuePairs = HttpUtilities.BuildKeyValuePairs(request);
|
||||
|
||||
var result = HttpUtilities.BuildEndPointWithKeyValuePairs(path, keyValuePairs);
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual("https://localhost:44364/api/core/AccessChannelPersons?PersonNumber=145&ActiveOnly=True&IncludeCards=False", result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user