first commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
using Landmark.OLA.Models.Loan.Validators;
|
||||
|
||||
namespace Landmark.OLA.Tests.Loan.Enums
|
||||
{
|
||||
//Check that all Loan Types are included in various settings
|
||||
|
||||
public class LoanTypeTest
|
||||
{
|
||||
private static List<LoanType> GetLoanTypes()
|
||||
{
|
||||
return [.. Enum.GetValues(typeof(LoanType))
|
||||
.Cast<LoanType>()
|
||||
.Where(e => !e.ToString().StartsWith("CC_"))];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TermLengthCheck()
|
||||
{
|
||||
_ = new LoanApplicationValidator();
|
||||
|
||||
foreach (var loanType in GetLoanTypes())
|
||||
{
|
||||
switch (loanType)
|
||||
{
|
||||
case LoanType.EQ_Mtg_Refi_Express:
|
||||
Assert.NotEmpty(TermLengths.MortgageRefiExpress);
|
||||
break;
|
||||
case LoanType.EQ_Home_Equity_Fixed:
|
||||
Assert.NotEmpty(TermLengths.HomeEquity);
|
||||
break;
|
||||
case LoanType.V_Vehicle:
|
||||
case LoanType.V_VehiclePreapproval:
|
||||
Assert.NotEmpty(TermLengths.TermsByYear);
|
||||
break;
|
||||
case LoanType.EQ_Mfg_Home_With_or_Without_Land:
|
||||
case LoanType.T_TrailerMotorhome:
|
||||
Assert.NotEmpty(TermLengths.MfdHomeAndRvByAmount);
|
||||
break;
|
||||
case LoanType.M_Boat:
|
||||
Assert.NotEmpty(TermLengths.BoatLoansByAmount);
|
||||
break;
|
||||
case LoanType.P_Powersport:
|
||||
Assert.NotEmpty(TermLengths.PowersportByAmount);
|
||||
break;
|
||||
case LoanType.S_Signature:
|
||||
Assert.NotEmpty(TermLengths.SignatureByAmount);
|
||||
break;
|
||||
case LoanType.S_Special:
|
||||
Assert.NotEmpty(TermLengths.Special);
|
||||
break;
|
||||
default:
|
||||
Assert.False(LoanApplicationValidator.IsTermRequired(loanType),
|
||||
$"{loanType} does not have any term lengths or is not excluded from the test.");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PurposeCheck()
|
||||
{
|
||||
foreach (var loanType in GetLoanTypes())
|
||||
{
|
||||
Assert.True(LoanPurpose.TypePurposes.ContainsKey(loanType), $"{loanType} does not have any set purposes.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LimitCheck()
|
||||
{
|
||||
foreach (var loanType in GetLoanTypes())
|
||||
{
|
||||
Assert.True(LoanLimits.Limits.ContainsKey(loanType), $"{loanType} does not have a set limit.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.Loan.Validators;
|
||||
|
||||
namespace Landmark.OLA.Tests.Loan.Validators
|
||||
{
|
||||
public class BranchConfigValidatorTest
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void NoDuplicateZipCodesTest()
|
||||
{
|
||||
var validator = new BranchConfigValidator();
|
||||
|
||||
var badConfig = new BranchConfig
|
||||
{
|
||||
BranchCodesByZip = [
|
||||
new BranchData("53207", 1234567),
|
||||
new BranchData("53207", 1234437)
|
||||
]
|
||||
};
|
||||
|
||||
var goodConfig = new BranchConfig
|
||||
{
|
||||
BranchCodesByZip = [
|
||||
new BranchData("53207", 1234567),
|
||||
new BranchData("53209", 1234437)
|
||||
]
|
||||
};
|
||||
|
||||
var singleConfig = new BranchConfig
|
||||
{
|
||||
BranchCodesByZip = [
|
||||
new BranchData("53209", 1234437)
|
||||
]
|
||||
};
|
||||
|
||||
Assert.True(validator.Validate(singleConfig).IsValid);
|
||||
Assert.True(validator.Validate(goodConfig).IsValid);
|
||||
Assert.False(validator.Validate(badConfig).IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Landmark.OLA.Models.Addresses;
|
||||
using Landmark.OLA.Models.Addresses.Enums;
|
||||
using Landmark.OLA.Models.Individuals;
|
||||
using Landmark.OLA.Models.Individuals.Enums;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
using Landmark.OLA.Models.Loan.Validators;
|
||||
using Landmark.OLA.Models.Residences;
|
||||
|
||||
namespace Landmark.OLA.Tests.Loan.Validators
|
||||
{
|
||||
public class LoanApplicationValidatorSpouseTest
|
||||
{
|
||||
private readonly LoanApplication _LoanApplication = new(DateTime.Parse("2018-02-21T16:52:47.62"))
|
||||
{
|
||||
LoanType = LoanType.CC_CashBack,
|
||||
RequestedAmount = 6000m,
|
||||
PrimaryContactMethod = "1234567890",
|
||||
Purpose = LoanPurpose.Purpose.Other,
|
||||
PrimaryBorrower = new Individual(id: new Guid("8066fa2a-16ba-4148-b28c-2926ba263c5f"))
|
||||
{
|
||||
FirstName = "Jane",
|
||||
MiddleInitial = "A",
|
||||
LastName = "Doe",
|
||||
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("bf7e502a-9830-43c6-b603-1a32294c7e1a"))
|
||||
{
|
||||
Address1 = "123 Main St",
|
||||
City = "New Berlin",
|
||||
State = StateOption.WI,
|
||||
Country = CountryOption.UnitedStates,
|
||||
PostalCode = "53151",
|
||||
MonthsResided = 12,
|
||||
ResidenceType = ResidenceTypeOption.Own,
|
||||
MonthlyPayment = 100,
|
||||
},
|
||||
MailingAddress = new Address(new Guid("f84db562-36a0-4039-9ce5-346a2ba6899b"))
|
||||
{
|
||||
Address1 = "321 Main St",
|
||||
City = "New Berlin",
|
||||
State = StateOption.WI,
|
||||
Country = CountryOption.UnitedStates,
|
||||
PostalCode = "53151"
|
||||
},
|
||||
Employers =
|
||||
[
|
||||
new Employer(employerId: new Guid("eee4efa3-327f-4ce5-9e8b-8c3e7a865fff"))
|
||||
{
|
||||
Name = "College Pro Painters",
|
||||
Title = "tester",
|
||||
WorkPhone = "9992245555",
|
||||
MonthsEmployed = 60,
|
||||
StartDate = new DateTime(2017, 01, 01),
|
||||
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
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
};
|
||||
|
||||
private readonly CoApplicant _CoApplicant = new(new Guid("ba99037f-df92-46d4-a477-ffecea1f4837"))
|
||||
{
|
||||
FirstName = "John",
|
||||
LastName = "Smith",
|
||||
DOB = new DateTime(2018, 7, 25),
|
||||
SSN = "111221111",
|
||||
Phone = "5555550983",
|
||||
PhoneType = PhoneType.Mobile,
|
||||
Email = "[email protected]",
|
||||
IsMarried = true,
|
||||
Language = LanguageOption.English,
|
||||
Address = new CurrentResidenceAddress(new Guid("ae795a5f-1ea3-4186-b4b8-e9f9b81e3059"))
|
||||
{
|
||||
Address1 = "339 1st St",
|
||||
Address2 = "#76",
|
||||
City = "Milwaukee",
|
||||
State = StateOption.WI,
|
||||
Country = CountryOption.UnitedStates,
|
||||
PostalCode = "53202",
|
||||
ResidenceType = ResidenceTypeOption.Rent,
|
||||
MonthsResided = 12,
|
||||
MonthlyPayment = 100,
|
||||
},
|
||||
PreviousAddresses =
|
||||
[
|
||||
new ResidenceAddress(new Guid("e7e881f0-d371-4371-8022-cce4f700e6d6"))
|
||||
{
|
||||
Address1 = "339 1st St",
|
||||
Address2 = "#80",
|
||||
City = "Milwaukee",
|
||||
State = StateOption.WI,
|
||||
Country = CountryOption.UnitedStates,
|
||||
PostalCode = "53202",
|
||||
ResidenceType = ResidenceTypeOption.Rent,
|
||||
MonthsResided = 6,
|
||||
},
|
||||
],
|
||||
Employers =
|
||||
[
|
||||
new Employer(employerId: new Guid("e8436884-0e6c-4144-8de5-1f44c7936a23"))
|
||||
{
|
||||
StartDate = new DateTime(2015, 01, 01),
|
||||
Name = "Chocolate Teapot Manfuacturing Inc",
|
||||
EmploymentType = EmploymentTypeOption.PartTime,
|
||||
Title = "Lead Teapot Assembler",
|
||||
WorkPhone = "5556783241",
|
||||
CurrentEmployer = true,
|
||||
Language = LanguageOption.English,
|
||||
Income = new Income
|
||||
{
|
||||
IncomeTypeCD = IncomeType.Salary,
|
||||
SourceName = "Work",
|
||||
Frequency = Frequency.Monthly,
|
||||
IncomeStatus = IncomeStatus.IncomeStatus_Included
|
||||
},
|
||||
},
|
||||
new Employer(employerId: new Guid("58d25f44-1260-428d-ac2c-d8804b06ed66"))
|
||||
{
|
||||
StartDate = new DateTime(2015, 01, 01),
|
||||
Name = "Vanilla Teapot Manfuacturing Coop",
|
||||
EmploymentType = EmploymentTypeOption.PartTime,
|
||||
Title = "Junior Teapot Assembler",
|
||||
WorkPhone = "5559572318",
|
||||
CurrentEmployer = true,
|
||||
Language = LanguageOption.English,
|
||||
Income = new Income
|
||||
{
|
||||
IncomeTypeCD = IncomeType.Salary,
|
||||
SourceName = "Work",
|
||||
Frequency = Frequency.Monthly,
|
||||
IncomeStatus = IncomeStatus.IncomeStatus_Included
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Unmarried()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
var result = validator.Validate(_LoanApplication);
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MarriedWithoutSpouseDataInWisconsin()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
var marriedWithoutSpouse = _LoanApplication;
|
||||
marriedWithoutSpouse.CoApplicant = _CoApplicant;
|
||||
|
||||
var result = validator.Validate(marriedWithoutSpouse);
|
||||
Assert.False(result.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CoappMarriedToPrimary()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
var marriedToPrimary = _LoanApplication;
|
||||
marriedToPrimary.CoApplicant = _CoApplicant;
|
||||
marriedToPrimary.CoApplicant.IsMarriedToPrimaryBorrower = true;
|
||||
|
||||
var result = validator.Validate(marriedToPrimary);
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CoappHasNonappSpouseInWisconsin()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
var coappHasNonappSpouse = _LoanApplication;
|
||||
coappHasNonappSpouse.CoApplicant = _CoApplicant;
|
||||
coappHasNonappSpouse.CoApplicant.NonApplicantSpouse = new MailableSpouse
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var result = validator.Validate(coappHasNonappSpouse);
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MarriedCoappWithoutSpouseDataInIllinois()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
var ilCoappMarriedWithoutSpouse = _LoanApplication;
|
||||
ilCoappMarriedWithoutSpouse.CoApplicant = _CoApplicant;
|
||||
ilCoappMarriedWithoutSpouse.CoApplicant.Address.State = StateOption.IL;
|
||||
|
||||
var result = validator.Validate(ilCoappMarriedWithoutSpouse);
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Xunit;
|
||||
using Landmark.OLA.Models.Assets;
|
||||
using Landmark.OLA.Models.Assets.Enums;
|
||||
using Landmark.OLA.Models.HomeMortgageDisclosureAct;
|
||||
using Landmark.OLA.Models.Individuals;
|
||||
using Landmark.OLA.Models.Individuals.Enums;
|
||||
using Landmark.OLA.Models.Loan;
|
||||
using Landmark.OLA.Models.Loan.Enums;
|
||||
using Landmark.OLA.Models.Loan.Validators;
|
||||
|
||||
namespace Landmark.OLA.Tests.Loan.Validators
|
||||
{
|
||||
public class LoanApplicationValidatorTest
|
||||
{
|
||||
|
||||
private List<LoanApplication> validTestApplications = [
|
||||
new LoanApplication
|
||||
{
|
||||
LoanType = LoanType.CC_CashBack,
|
||||
PrimaryContactMethod = "1234567890",
|
||||
Purpose = LoanPurpose.Purpose.Other,
|
||||
RequestedAmount = 5000,
|
||||
PrimaryBorrower = new Individual(),
|
||||
},
|
||||
new LoanApplication
|
||||
{
|
||||
LoanType = LoanType.EQ_Mtg_Refi_Express,
|
||||
PrimaryContactMethod = "1234567890",
|
||||
Purpose = LoanPurpose.Purpose.Home_Refinance,
|
||||
TermLengthInMonths = 144,
|
||||
RequestedAmount = 10000,
|
||||
PrimaryBorrower = new Individual(new Hmda
|
||||
{
|
||||
Ethnicities = [Ethnicity.NotProvided],
|
||||
Races = [Race.NotProvided],
|
||||
Sexes = [Sex.NotProvided],
|
||||
}),
|
||||
RealEstate = new RealEstate
|
||||
{
|
||||
//This is valid from a business perspective. Model Validation would flag the empty object.
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
private List<LoanApplication> invalidTestApplications = [
|
||||
|
||||
new LoanApplication
|
||||
{
|
||||
LoanType = LoanType.V_Vehicle,
|
||||
Purpose = LoanPurpose.Purpose.Purchase,
|
||||
TermLengthInMonths = 36,
|
||||
RequestedAmount = 5000,
|
||||
PrimaryBorrower = new Individual(),
|
||||
Vehicle = new Vehicle
|
||||
{
|
||||
Type = VehicleType.Automobile,
|
||||
}
|
||||
},
|
||||
new LoanApplication
|
||||
{
|
||||
LoanType = LoanType.EQ_Mtg_Refi_Express,
|
||||
Purpose = LoanPurpose.Purpose.Home_Refinance,
|
||||
TermLengthInMonths = 144,
|
||||
RequestedAmount = 5000,
|
||||
PrimaryBorrower = new Individual(),
|
||||
}
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void IsValidTermLengthTest()
|
||||
{
|
||||
var validator = new LoanApplicationValidator();
|
||||
|
||||
using (StreamReader file = File.OpenText("TestData" + System.IO.Path.DirectorySeparatorChar +
|
||||
"json" + System.IO.Path.DirectorySeparatorChar + "TestValidatorLoans.json"))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
JObject o2 = (JObject)JToken.ReadFrom(reader);
|
||||
JArray a = (JArray)o2["validLoans"];
|
||||
IList<LoanApplication> validTestApps = a.ToObject<IList<LoanApplication>>();
|
||||
foreach (var loan in validTestApps)
|
||||
{
|
||||
Assert.True(validator.Validate(loan).IsValid);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( var loan in validTestApplications )
|
||||
{
|
||||
Assert.True(validator.Validate(loan).IsValid);
|
||||
}
|
||||
|
||||
foreach (var loan in invalidTestApplications)
|
||||
{
|
||||
Assert.False(validator.Validate(loan).IsValid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSignatureTermValidityTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMfdHomeAndRvTermValidityTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetVehicleTermValidityTest()
|
||||
{
|
||||
_ = new LoanApplicationValidator();
|
||||
|
||||
using StreamReader file = File.OpenText("TestData" + Path.DirectorySeparatorChar +
|
||||
"json" + Path.DirectorySeparatorChar + "TestVehicleTermValidity.json");
|
||||
using JsonTextReader reader = new(file);
|
||||
JObject allData = (JObject)JToken.ReadFrom(reader);
|
||||
JArray vehicles = (JArray)allData["vehicles"];
|
||||
IList<Vehicle> validTestVehicles = vehicles.ToObject<IList<Vehicle>>();
|
||||
foreach (var vehicle in validTestVehicles)
|
||||
{
|
||||
List<int> termList = LoanApplicationValidator.GetVehicleTermList(vehicle);
|
||||
Assert.NotNull(termList);
|
||||
Assert.NotEmpty(termList);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetBoatTermValidityTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetPowersportTermValidityTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user