Files
monorepo/LCU.API.Internal.DocumentIngestor/LCU.API.Internal.DocumentIngestorTests/Services/AttributeDeterminingServices/AccountOwnerDeterminingServiceTest.cs
T
2026-03-25 14:50:13 -05:00

613 lines
23 KiB
C#

using LCU.API.Internal.DocumentIngestor.Services.AttributeDeterminingServices;
using LCU.API.Internal.DocumentIngestor.Services.MicroApiServices;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Mixed;
using LCU.Library.Internal.DocumentIngestorModels.Entities;
using LCU.Library.Internal.DocumentIngestorModels.Enums;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LCU.API.Internal.DocumentIngestorTests.Services.AttributeDeterminingServices;
public class AccountOwnerDeterminingServiceTest
{
private AccountOwnerDeterminingService _accountOwnerDeterminingService;
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
[SetUp]
public void Setup()
{
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
_accountOwnerDeterminingService = new AccountOwnerDeterminingService(_mockCoreApiWrapperService.Object);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_PersonNumberFound_Success()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.AreEqual("1", resultPayload.PersonNumbers?[0]);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_PersonNumberNotFound_OrganizationFound_Success()
{
var orgName = "The Big Company";
var accountNumber = "9999";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
ByOrgNbr = 2,
OrganizationName = orgName,
IsPrimaryOwner = true
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(orgName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.AreEqual("2", resultPayload.OrganizationNumbers?[0]);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_PersonNumberNotFound_OrganizationNotFound_Failure()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>();
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_NoPrimaryOwner_Failure()
{
var fullName = "Bill B Billson";
var accountNumber = "";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 2,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = false
},
new()
{
PersonNumber = 5,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = false
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByPersonName(fullName)).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.IsFalse(result.Success);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual(accountNumber, resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_TooManyOwners_Failure()
{
var fullName = "Bill B Billson";
var accountNumber = "";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 2,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
},
new()
{
PersonNumber = 5,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByPersonName(fullName)).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.IsFalse(result.Success);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual(accountNumber, resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DeterminePrimaryOwnerAttributeForDnaDocument_EntityNameDoesNotMatch_Failure()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
ByOrgNbr = 2,
FirstName = "Pete",
MiddleInitial = "P",
LastName = "Peterson",
IsPrimaryOwner = true
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, null);
var resultPayload = result.Payload;
Assert.IsFalse(result.Success);
Assert.AreEqual("2", resultPayload.OrganizationNumbers?[0]);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_OwnerOverridePerson_Success()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var documentProcessingInfoId = 123;
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var ownerOverrideRequest = new OwnerOverrideInfo()
{
DocumentProcessingInfoId = documentProcessingInfoId,
EntityId = "888888",
EntityType = EntityTypes.Person,
UserName = "Test Tester"
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, ownerOverrideRequest);
var resultPayload = result.Payload;
Assert.AreEqual("888888", resultPayload.PersonNumbers?[0]);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_OwnerOverrideOrganization_Success()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var documentProcessingInfoId = 123;
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
ByOrgNbr = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var ownerOverrideRequest = new OwnerOverrideInfo()
{
DocumentProcessingInfoId = documentProcessingInfoId,
EntityId = "888888",
EntityType = EntityTypes.Organization,
UserName = "Test Tester"
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, ownerOverrideRequest);
var resultPayload = result.Payload;
Assert.AreEqual("888888", resultPayload.OrganizationNumbers?[0]);
Assert.IsEmpty(resultPayload.PersonNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeForDnaDocument_OwnerOverrideUnknown_Success()
{
var fullName = "Bill B Billson";
var accountNumber = "9999";
var documentProcessingInfoId = 123;
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var ownerOverrideRequest = new OwnerOverrideInfo()
{
DocumentProcessingInfoId = documentProcessingInfoId,
EntityId = "888888",
EntityType = EntityTypes.Unknown,
UserName = "Test Tester"
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttribute(fullName, accountNumber, creationDate, ownerOverrideRequest);
var resultPayload = result.Payload;
Assert.AreEqual("1", resultPayload.PersonNumbers?[0]);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByPersonName(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByOrganizationName(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_StartsWithM_PersonNumberFound_Success()
{
var memberNumberOrUserId = "M1234";
var accountNumber = "9999";
var docType = "MTG_NT_110_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1234,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var personOrganization = new PersonOrganization()
{
PersonNumber = "1234",
OrganizationNumber = null
};
var agreementAccount = new AgreementAccount()
{
AccountNumber = 9999,
AccountDescription = "PREMIUM CHECKING",
MajorAccountTypeCode = "CK",
TaxReportForPersonNumber = 1234,
TaxReportForOrgNumber = null,
OvrDeliveryMethCD = "PRNT",
AccountOwner = new AgreementAccountOwner
{
AccountNumber = 9999,
AgreementNumber = 0,
UserId = null,
PersonNumber = 0
}
};
_mockCoreApiWrapperService.Setup(x => x.GetPersonOrOrganizationNumberByMemberId(It.IsAny<string>())).ReturnsAsync(personOrganization).Verifiable();
_mockCoreApiWrapperService.Setup(x => x.GetAgreementAccountByAccountId(It.IsAny<string>())).ReturnsAsync(agreementAccount);
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
var resultPayload = result.Payload;
Assert.IsTrue(result.Success);
Assert.AreEqual("1234", resultPayload.PersonNumbers?[0]);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementByUserId(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementAccountByAccountId(It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_StartsWithoutM_PersonNumberFound_Success()
{
var memberNumberOrUserId = "1234";
var accountNumber = "9999";
var docType = "OPS_NT_119_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1234,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var personOrganization = new PersonOrganization()
{
PersonNumber = "1234",
OrganizationNumber = null
};
var agreementAccount = new AgreementAccount()
{
AccountNumber = 9999,
AccountDescription = "PREMIUM CHECKING",
MajorAccountTypeCode = "CK",
TaxReportForPersonNumber = 1234,
TaxReportForOrgNumber = null,
OvrDeliveryMethCD = "PRNT",
AccountOwner = new AgreementAccountOwner
{
AccountNumber = 9999,
AgreementNumber = 0,
UserId = null,
PersonNumber = 0
}
};
_mockCoreApiWrapperService.Setup(x => x.GetPersonOrOrganizationNumberByMemberId(It.IsAny<string>())).ReturnsAsync(personOrganization).Verifiable();
_mockCoreApiWrapperService.Setup(x => x.GetAgreementAccountByAccountId(It.IsAny<string>())).ReturnsAsync(agreementAccount);
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
var resultPayload = result.Payload;
Assert.IsTrue(result.Success);
Assert.AreEqual("1234", resultPayload.PersonNumbers?[0]);
Assert.IsEmpty(resultPayload.OrganizationNumbers);
Assert.AreEqual("9999", resultPayload.AccountNumber);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementByUserId(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementAccountByAccountId(It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_PersonNumberNotFound_OrganizationNotFound_Failure()
{
var memberNumberOrUserId = "M1234";
var accountNumber = "9999";
var docType = "OPS_NT_119_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var personOrganization = new PersonOrganization()
{
PersonNumber = null,
OrganizationNumber = null
};
_mockCoreApiWrapperService.Setup(x => x.GetPersonOrOrganizationNumberByMemberId(It.IsAny<string>())).ReturnsAsync(personOrganization).Verifiable();
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
var resultPayload = result.Payload;
Assert.IsFalse(result.Success);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementByUserId(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_AgreementNotFound_Failure()
{
var memberNumberOrUserId = "1234";
var accountNumber = "9999";
var docType = "MTG_NT_110_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
Assert.IsFalse(result.Success);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementByUserId(It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementAccountByAccountId(It.IsAny<string>()), Times.Never);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_PersonNumberDoesNotMatch_Failure()
{
var memberNumberOrUserId = "M1234";
var accountNumber = "9999";
var docType = "OPS_NT_119_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true
}
};
var personOrganization = new PersonOrganization()
{
PersonNumber = "2",
OrganizationNumber = null
};
var agreementAccount = new AgreementAccount()
{
AccountNumber = 9999,
AccountDescription = "PREMIUM CHECKING",
MajorAccountTypeCode = "CK",
TaxReportForPersonNumber = 1234,
TaxReportForOrgNumber = null,
OvrDeliveryMethCD = "PRNT",
AccountOwner = new AgreementAccountOwner
{
AccountNumber = 9999,
AgreementNumber = 0,
UserId = null,
PersonNumber = 0
}
};
_mockCoreApiWrapperService.Setup(x => x.GetPersonOrOrganizationNumberByMemberId(It.IsAny<string>())).ReturnsAsync(personOrganization).Verifiable();
_mockCoreApiWrapperService.Setup(x => x.GetAgreementAccountByAccountId(It.IsAny<string>())).ReturnsAsync(agreementAccount);
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
Assert.IsFalse(result.Success);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementByUserId(It.IsAny<string>()), Times.Never);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementAccountByAccountId(It.IsAny<string>()), Times.Once);
}
[Test]
public async Task DetermineAccountOwnerAttributeByMemberNumberOrUserId_OrganizationNumberDoesNotMatch_Failure()
{
var memberNumberOrUserId = "M1234";
var accountNumber = "9999";
var docType = "OPS_NT_119_01";
var creationDate = new DateTime(2022, 01, 01);
var accountOwnership = new List<AccountOwnership>
{
new()
{
PersonNumber = 1,
FirstName = "Bill",
MiddleInitial = "B",
LastName = "Billson",
IsPrimaryOwner = true,
ByOrgNbr = 123
}
};
var personOrganization = new PersonOrganization()
{
PersonNumber = null,
OrganizationNumber = "456"
};
var agreementAccount = new AgreementAccount()
{
AccountNumber = 9999,
AccountDescription = "PREMIUM CHECKING",
MajorAccountTypeCode = "CK",
TaxReportForPersonNumber = null,
TaxReportForOrgNumber = 123,
OvrDeliveryMethCD = "PRNT",
AccountOwner = new AgreementAccountOwner
{
AccountNumber = 9999,
AgreementNumber = 0,
UserId = null,
PersonNumber = 0
}
};
_mockCoreApiWrapperService.Setup(x => x.GetPersonOrOrganizationNumberByMemberId(It.IsAny<string>())).ReturnsAsync(personOrganization).Verifiable();
_mockCoreApiWrapperService.Setup(x => x.GetAgreementAccountByAccountId(It.IsAny<string>())).ReturnsAsync(agreementAccount);
_mockCoreApiWrapperService.Setup(x => x.GetOwnersByAccountNumber(accountNumber, creationDate.ToShortDateString())).ReturnsAsync(accountOwnership);
var result = await _accountOwnerDeterminingService.DetermineAccountOwnerAttributeByMemberNumberOrUserId(memberNumberOrUserId, accountNumber, docType, creationDate, null);
Assert.IsFalse(result.Success);
_mockCoreApiWrapperService.Verify(x => x.GetOwnersByAccountNumber(It.IsAny<string>(), It.IsAny<string>()), Times.Once);
_mockCoreApiWrapperService.Verify(x => x.GetAgreementAccountByAccountId(It.IsAny<string>()), Times.Once);
}
}