Files
monorepo/LCU.API.Internal.OnlineLoanApp/CRIF.ACTion.Tests/Loan/Individuals/PartiesSectionTest.cs
T
2026-03-11 11:18:25 -05:00

452 lines
15 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Xunit;
using CRIF.ACTion.Common;
using CRIF.ACTion.Loan.Individuals;
using Landmark.OLA.Models;
using Landmark.OLA.Models.Addresses;
using Landmark.OLA.Models.Addresses.Enums;
using Landmark.OLA.Models.HomeMortgageDisclosureAct;
using Landmark.OLA.Models.Individuals;
using Landmark.OLA.Models.Individuals.Enums;
using Landmark.OLA.Models.Loan.Enums;
using Landmark.OLA.Models.Residences;
namespace CRIF.ACTion.Tests.Loan.Individuals
{
public class PartiesSectionTest
{
private static Guid TestGuid => new("e4a1a31a-3985-4f76-955c-9227c9c94ba8");
private static readonly IApplicant TestIndividual = new Individual(new Guid("67755afb-b125-4a48-959e-7cedead90f8f"))
{
FirstName = "Jane",
MiddleInitial = "A",
LastName = "Doe",
Suffix = Suffix.III,
DOB = new DateTime(2018, 7, 9),
Phone = "1235555555",
PhoneType = PhoneType.Home,
SSN = "000090001",
Email = "[email protected]",
IsMarried = false,
Language = LanguageOption.English,
Address = new CurrentResidenceAddress(new Guid("b09444c1-c12f-4c3e-b787-04c44b6be0c4"))
{
Address1 = "123 Main St",
City = "New Berlin",
State = StateOption.WI,
Country = CountryOption.UnitedStates,
PostalCode = "53151",
MonthsResided = 12,
ResidenceType = ResidenceTypeOption.Own,
MonthlyPayment = 100,
},
OtherIncomes =
[
new Income
{
IncomeTypeCD = IncomeType.SocialSecurity,
Frequency = Frequency.Monthly,
SourceName = "Freeform Text",
AmountPerPeriod = 123.45m,
IncomeStatus = IncomeStatus.IncomeStatus_Included,
},
new Income
{
IncomeTypeCD = IncomeType.Alimony,
Frequency = Frequency.Annually,
SourceName = "Child Support",
AmountPerPeriod = 600,
IncomeStatus = IncomeStatus.IncomeStatus_Included,
}
],
Employers =
[
new Employer(employerId: new Guid("2fd067f2-bd3d-4053-990e-f4282180db63"))
{
Name = "College Pro Painters",
Title = "tester",
WorkPhone = "9992245555",
StartDate = new DateTime(2017, 01, 01),
MonthsEmployed = 60,
CurrentEmployer = true,
EmploymentType = EmploymentTypeOption.FullTime,
Language = LanguageOption.English,
Income = new Income
{
IncomeTypeCD = IncomeType.Salary,
SourceName = "Salary",
AmountPerPeriod = 5000.0m,
Frequency = Frequency.Annually,
IncomeStatus = IncomeStatus.IncomeStatus_Included
}
}
]
};
public static IEnumerable<Object[]> GetSuffixElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var suffixElements = PartiesSection.GetSuffixElement(TestIndividual);
yield return new Object[] {
suffixElements,
"GetSuffixElement.xml"
};
}
public static IEnumerable<Object[]> GetTradesElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var mockPropertyLot = new PropertyLot
{
RentalAmt = 150
};
var tradesElement = PartiesSection.GetTradesElement(TestIndividual, mockPropertyLot);
yield return new Object[] {
tradesElement,
"GetTradesElement.xml"
};
}
public static IEnumerable<Object[]> AddChannelParty()
{
var section = new PartiesSection("", TestCommon.GetTestSettings());
section.AddSourceChannelParty(TestGuid, LoanType.EQ_HELOC_Flex);
yield return new Object[] {
section.Build(),
"AddChannelParty.xml"
};
}
public static IEnumerable<Object[]> AddEmployer()
{
var section = new PartiesSection("", TestCommon.GetTestSettings());
section.AddEmployer(TestIndividual.Employers.First());
yield return new Object[] {
section.Build(),
"AddEmployer.xml"
};
}
public static IEnumerable<Object[]> GetContactMechanismElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var contactElement = PartiesSection.GetContactMechanismElement(TestIndividual.Phone, ContactMechanisms.CrifContactMechanism.HomePhone);
yield return new Object[] {
contactElement,
"GetContactMechanismElement.xml"
};
}
public static IEnumerable<Object[]> GetContactMechanismsSectionElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var element = PartiesSection.GetContactMechanismsSectionElement(TestIndividual);
yield return new Object[] {
element,
"GetContactMechanismsSectionElement.xml"
};
}
public static IEnumerable<Object[]> GetEmployerContactMechanismsSectionElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var element = PartiesSection.GetEmployerContactMechanismsSectionElement(TestIndividual.Employers.First());
yield return new Object[] {
element,
"GetEmployerContactMechanismsSectionElement.xml"
};
}
public static IEnumerable<Object[]> GetIncomesSectionElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var element = PartiesSection.GetIncomesSectionElement(TestIndividual);
yield return new Object[] {
element,
"GetIncomesSectionElement.xml"
};
}
public static IEnumerable<Object[]> GetMaritalStatusElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var isMarried = PartiesSection.GetMaritalStatusElement(true);
yield return new Object[] {
isMarried,
"GetMaritalStatusElement-True.xml"
};
var isNotMarried = PartiesSection.GetMaritalStatusElement(false);
yield return new Object[] {
isNotMarried,
"GetMaritalStatusElement-False.xml"
};
}
public static IEnumerable<Object[]> GetPartyRelationshipsSectionElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var element = PartiesSection.GetApplicantPartyRelationshipsSectionElement(TestIndividual);
yield return new Object[] {
element,
"GetPartyRelationshipsSectionElement.xml"
};
}
public static IEnumerable<Object[]> AddIndividual()
{
var section = new PartiesSection("", TestCommon.GetTestSettings());
section.AddApplicant(TestIndividual);
yield return new Object[] {
section.Build(),
"AddIndividual.xml"
};
}
public static IEnumerable<Object[]> AddOrganizationParty()
{
var section = new PartiesSection("", TestCommon.GetTestSettings());
section.AddOrganizationParty(TestGuid);
yield return new Object[] {
section.Build(),
"AddOrganizationParty.xml"
};
}
public static IEnumerable<Object[]> GetAddressContactMechanismElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var currentAddress = PartiesSection.GetAddressContactMechanismElement(TestGuid, ContactMechanisms.CrifContactMechanism.CurrentAddress);
yield return new Object[] {
currentAddress,
"GetAddressContactMechanismElement-Current.xml"
};
var previousAddress = PartiesSection.GetAddressContactMechanismElement(TestGuid, ContactMechanisms.CrifContactMechanism.PreviousAddress);
yield return new Object[] {
previousAddress,
"GetAddressContactMechanismElement.xml"
};
}
public static IEnumerable<Object[]> GetEthnicitiesElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var individualEthnicityAndDidNotFurnish = new Individual
{
HmdaValues = new Hmda
{
Ethnicities = [Ethnicity.Cuban],
}
};
yield return new Object[] {
PartiesSection.GetEthnicitiesElement(individualEthnicityAndDidNotFurnish),
"GetEthnicitiesElement.xml"
};
var individual = new Individual
{
HmdaValues = new Hmda
{
Ethnicities =
[
Ethnicity.Cuban,
Ethnicity.NotProvided,
]
}
};
yield return new Object[] {
PartiesSection.GetEthnicitiesElement(individual),
"GetEthnicitiesElement.xml"
};
var individualDidNotFurnish = new Individual
{
HmdaValues = new Hmda
{
Ethnicities =
[
Ethnicity.NotProvided,
]
}
};
yield return new Object[] {
PartiesSection.GetEthnicitiesElement(individualDidNotFurnish),
"GetEthnicitiesElement-DidNotProvide.xml"
};
}
public static IEnumerable<Object[]> GetRacesElement()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var individual = new Individual
{
HmdaValues = new Hmda
{
Races =
[
Race.AmericanIndianAlaskaNative,
Race.OtherPacificIslander,
],
AmericanIndianAlaskaNativeTribe = "Forest County Potawatomi",
OtherAsianRace = "Hmong",
}
};
yield return new Object[] {
PartiesSection.GetRacesElement(individual),
"GetRacesElement.xml"
};
var individualWithNotProvided = new Individual
{
HmdaValues = new Hmda
{
Races =
[
Race.AmericanIndianAlaskaNative,
Race.OtherPacificIslander,
Race.NotProvided
],
AmericanIndianAlaskaNativeTribe = "Forest County Potawatomi",
OtherAsianRace = "Hmong",
}
};
yield return new Object[] {
PartiesSection.GetRacesElement(individualWithNotProvided),
"GetRacesElement.xml"
};
var individualOnlyNotProvided = new Individual
{
HmdaValues = new Hmda
{
Races =
[
Race.NotProvided
]
}
};
yield return new Object[] {
PartiesSection.GetRacesElement(individualOnlyNotProvided),
"GetRacesElement-NotProvided.xml"
};
}
public static IEnumerable<Object[]> GetSexAttributes()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var individual = new Individual
{
HmdaValues = new Hmda
{
Sexes =
[
Sex.Female,
Sex.NotProvided,
]
}
};
var individualElement = new XElement(CrifNamespaces.Common + "individual", PartiesSection.GetSexAttributes(individual));
yield return new Object[] {
individualElement,
"GetSexAttributes.xml"
};
var individualNotProvided = new Individual
{
HmdaValues = new Hmda
{
Sexes =
[
Sex.NotProvided,
]
}
};
individualElement = new XElement(CrifNamespaces.Common + "individual", PartiesSection.GetSexAttributes(individualNotProvided));
yield return new Object[] {
individualElement,
"GetSexAttributes-NotProvided.xml"
};
}
public static IEnumerable<Object[]> GetNoCoApplicantDetermination()
{
_ = new PartiesSection("", TestCommon.GetTestSettings());
var individualElement = new XElement(CrifNamespaces.Common + "determinations");
PartiesSection.AddNonApplicantHmdaDetermination(individualElement);
yield return new object[]
{
individualElement,
"GetNoCoApplicantDetermination.xml"
};
}
[Theory]
[MemberData(nameof(AddChannelParty))]
[MemberData(nameof(AddEmployer))]
[MemberData(nameof(AddIndividual))]
[MemberData(nameof(AddOrganizationParty))]
[MemberData(nameof(GetContactMechanismElement))]
[MemberData(nameof(GetContactMechanismsSectionElement))]
[MemberData(nameof(GetEmployerContactMechanismsSectionElement))]
[MemberData(nameof(GetIncomesSectionElement))]
[MemberData(nameof(GetMaritalStatusElement))]
[MemberData(nameof(GetAddressContactMechanismElement))]
[MemberData(nameof(GetPartyRelationshipsSectionElement))]
[MemberData(nameof(GetEthnicitiesElement))]
[MemberData(nameof(GetRacesElement))]
[MemberData(nameof(GetSexAttributes))]
[MemberData(nameof(GetTradesElement))]
[MemberData(nameof(GetSuffixElement))]
[MemberData(nameof(GetNoCoApplicantDetermination))]
public void CheckXmlCreation(XElement xElement, string fileName)
{
Assert.True(ModelValidator.TryValidate(xElement));
var result = TestCommon.Compare(xElement,
"ExampleXML" + System.IO.Path.DirectorySeparatorChar + "PartiesSection"
+ System.IO.Path.DirectorySeparatorChar + fileName);
Assert.Empty(result);
}
}
}