first commit
This commit is contained in:
+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