first commit

This commit is contained in:
Zeeshaun
2026-03-11 11:18:25 -05:00
commit f3cb730f3b
472 changed files with 53651 additions and 0 deletions
@@ -0,0 +1,55 @@
using System;
using Xunit;
using Landmark.OLA.Models.Addresses;
using Landmark.OLA.Models.Addresses.Enums;
using Landmark.OLA.Models.Addresses.Validators;
namespace Landmark.OLA.Tests.Addresses.Validators
{
public class AddressValidatorTest
{
[Fact]
public void TestWithNull()
{
Address address = null;
Assert.Throws<InvalidOperationException>(() => new AddressValidator().Validate(address).IsValid);
}
[Theory]
[InlineData(false, null, null, null, null, null, null, null)]
[InlineData(true, "address1", "address2", "city", "postalCode", "ext", "WI", "UnitedStates")]
[InlineData(true, "address1", null, "city", "postalCode", null, "WI", null)]
[InlineData(false, null, null, "city", "postalCode", null, "WI", null)]
[InlineData(false, "address1", null, null, "postalCode", null, "WI", null)]
[InlineData(false, "address1", null, "city", null, null, "WI", null)]
[InlineData(false, "address1", null, "city", "postalCode", null, null, null)]
[InlineData(false, "address1", null, "city", null, null, null, null)]
public void TestCombinationsWithValidStateAndCountry(bool expected, string address1, string address2, string city, string postalCode, string postalCodeExt, string state, string country)
{
StateOption? stateOptionToUse = null;
if(!string.IsNullOrEmpty(state)) {
Enum.TryParse(state, out StateOption stateOption);
stateOptionToUse = stateOption;
}
CountryOption? countryOptionToUse = null;
if (!string.IsNullOrEmpty(country))
{
Enum.TryParse(state, out CountryOption countryOption);
countryOptionToUse = countryOption;
}
Address address = new() {
Address1 = address1,
Address2 = address2,
City = city,
State = stateOptionToUse,
PostalCode = postalCode,
Country = countryOptionToUse,
PostalCodeExt = postalCodeExt
};
Assert.Equal(expected, new AddressValidator().Validate(address).IsValid);
}
}
}
@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Mvc;
using Xunit;
using Moq;
using Landmark.OLA.Models.Vendor;
using Landmark.OLA.Models.Addresses;
using Landmark.OLA.Application.Controllers;
namespace Landmark.OLA.Tests.Controllers
{
public class AddressValidationTest
{
// TEST: public async Task<IActionResult> Post([FromBody] Address address)
[Fact]
public async void Address_Validate_OK()
{
var mockUspsClient = new Mock<IUspsVendorClient>();
var postError = new Models.ClientError() { Message = "Error Jim Robinson" };
var postAddress = new Address() {
Address1 = "111 S 1st st",
City = "Milwaukee",
State = Models.Addresses.Enums.StateOption.WI,
PostalCode = "53207"
};
// arrange
var controller = new AddressValidationController(mockUspsClient.Object);
// act
var result = await controller.Post(postAddress);
var okResult = result as OkObjectResult;
// assert
Assert.NotNull(okResult);
Assert.Equal(200, okResult.StatusCode);
}
}
}
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using Xunit;
using Landmark.OLA.Application.Controllers;
namespace Landmark.OLA.Tests.Controllers
{
public class LoggingTest
{
[Fact]
public void Logging_Error_OK()
{
var postError = new Models.ClientError() { Message = "Error Jim Robinson" };
// arrange
var controller = new LoggingController();
// act
var result = controller.Post(postError);
var okResult = result as OkResult;
// assert
Assert.NotNull(okResult);
Assert.Equal(200, okResult.StatusCode);
}
}
}
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc;
using Xunit;
using Moq;
using Landmark.OLA.Application.Common.Domain;
using Landmark.OLA.Application.Controllers;
using Landmark.OLA.Application.DataAccess;
using Landmark.OLA.Models.Loan;
namespace Landmark.OLA.Tests.Controllers
{
public class UiSettingsTest
{
[Fact]
public void UiSettings_Returns_OK()
{
var _branchConfig = new BranchConfig
{
Id = "012345678901234567890123456789012345"
};
var mockRepo = new Mock<IBranchDataAccess>();
mockRepo.Setup(repo => repo.GetBranchConfig()).Returns(_branchConfig);
var mockRepo2 = new Mock<IConfigurationAccess>();
// arrange
var controller = new UiSettingsController(new UiSettings(), mockRepo.Object, mockRepo2.Object);
// act
var result = controller.Get();
var okResult = result as OkObjectResult;
// assert
Assert.NotNull(okResult);
Assert.Equal(200, okResult.StatusCode);
}
}
}
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="XmlDiffPatch.Core" Version="1.0.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Landmark.OLA.Application\Landmark.OLA.Application.csproj" />
<ProjectReference Include="..\Landmark.OLA.Models\Landmark.OLA.Models.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="TestData\json\TestVehicleTermValidity.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\json\TestValidatorLoans.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
@@ -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.");
}
}
}
}
@@ -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);
}
}
}
@@ -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);
}
}
}
@@ -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()
{
}
}
}
@@ -0,0 +1,128 @@
using System;
using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using Xunit;
using Landmark.OLA.Tests.TestData;
using Landmark.OLA.Models.Loan;
using Landmark.OLA.Models;
namespace Landmark.OLA.Tests
{
public class ModelValidatorTest
{
[Theory]
[MemberData(nameof(TestIndividuals.GetValidTestIndividuals), MemberType = typeof(TestIndividuals))]
[MemberData(nameof(TestAddresses.GetValidTestAddresses), MemberType = typeof(TestAddresses))]
[MemberData(nameof(TestEmployers.GetValidTestEmployers), MemberType = typeof(TestEmployers))]
public void ExpectValidModelsTest(object testData)
{
ModelValidator.Validate(testData);
}
[Theory]
[MemberData(nameof(TestIndividuals.GetInvalidTestIndividuals), MemberType = typeof(TestIndividuals))]
[MemberData(nameof(TestAddresses.GetInvalidTestAddresses), MemberType = typeof(TestAddresses))]
[MemberData(nameof(TestEmployers.GetInvalidTestEmployers), MemberType = typeof(TestEmployers))]
public void ExpectInvalidModelsTest(object testData)
{
Assert.Throws<ArgumentException>(() => ModelValidator.Validate(testData));
}
[Fact]
public void VerifyDataAnnotations()
{
string nspace = "Landmark.OLA.Models";
//LoanApplication is in the namespace we want to look into
Assembly modelAssembly = typeof(LoanApplication).GetTypeInfo().Assembly;
var models = modelAssembly.GetTypes()
.Where(t => t.IsClass == true && string.Equals(t.Namespace, nspace, StringComparison.Ordinal))
.ToArray();
var missingValidation = new List<string>();
foreach(var model in models)
{
var fields = model.GetProperties()
.Where(x => !x.PropertyType.Namespace.StartsWith("Landmark")
&& x.PropertyType != typeof(bool)
&& x.PropertyType != typeof(Guid)
&& x.PropertyType != typeof(Enum));
foreach (var field in fields)
{
var hasSizeValidation = false;
var fieldType = field.PropertyType;
if (fieldType.IsGenericType)
{
if (fieldType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
fieldType = Nullable.GetUnderlyingType(fieldType);
}
else
{
fieldType = fieldType.GetGenericArguments()[0];
}
}
if (fieldType.BaseType == typeof(Enum)
|| fieldType == typeof(bool)
|| fieldType == typeof(Guid)
|| fieldType == typeof(DateTime)
|| fieldType.IsClass)
{
//enum, bool, guid are restricted to specific sizes or values
//DateTime seems safe?
//Landmark classes will already have their validation checked
hasSizeValidation = true;
}
if(field.SetMethod?.IsPrivate ?? false)
{
//If inbound data ins't accepted we won't require validation
hasSizeValidation = true;
}
if (!hasSizeValidation)
{
foreach (var attribute in field.GetCustomAttributes()
.Where(x => x.TypeId.ToString().StartsWith("System.ComponentModel.DataAnnotations")))
{
var sizeValidationAttributeTypes = new List<Type>
{
typeof(System.ComponentModel.DataAnnotations.MaxLengthAttribute),
typeof(System.ComponentModel.DataAnnotations.RangeAttribute),
typeof(System.ComponentModel.DataAnnotations.StringLengthAttribute),
};
if (sizeValidationAttributeTypes.Contains(attribute.GetType()))
{
hasSizeValidation = true;
}
}
}
if(!hasSizeValidation)
{
missingValidation.Add($"{model.Name} : {field.Name}");
}
}
}
Assert.Empty(missingValidation);
}
private T GetAttributeFrom<T>(object instance, string propertyName) where T : Attribute
{
var attrType = typeof(T);
var property = instance.GetType().GetProperty(propertyName);
return (T)property.GetCustomAttributes(attrType, false).First();
}
}
}
@@ -0,0 +1,70 @@
using System.Collections.Generic;
using Xunit;
using Landmark.OLA.Application.Services;
using Landmark.OLA.Models.Core;
namespace Landmark.OLA.Tests.Services
{
public class CoreAccessServiceTest
{
[Fact]
public void FindOwners_VariableResponses()
{
var service = new CoreAccessService();
// arrange
var owners = new List<CoreMemberOwner>()
{
new()
{
Name = "John Doe",
BirthDate = "2000-01-01",
TaxId = "111-22-3333"
},
new()
{
Name = "Jane Doe",
BirthDate = null,
TaxId = "111-22-4444"
},
new()
{
Name = "Janus Doe",
BirthDate = "1995-08-08",
TaxId = null
},
new()
{
Name = "Tester Doe",
BirthDate = "1995-09-08",
TaxId = "123-45-6789"
}
};
var find1 = new Application.Controllers.OnlineIdentityFormData() {
DateOfBirth = "09/08/1995",
SocialSecurityNumber = "6789"
};
var noFind1 = new Application.Controllers.OnlineIdentityFormData() {
DateOfBirth = "09/08/1995",
SocialSecurityNumber = "3333"
};
var noFind2 = new Application.Controllers.OnlineIdentityFormData() {
DateOfBirth = "01/01/2000",
SocialSecurityNumber = "6789"
};
// act
var found1 = service.FindMatchingOwner(find1, owners);
var notFound1 = service.FindMatchingOwner(noFind1, owners);
var notFound2 = service.FindMatchingOwner(noFind2, owners);
// assert
Assert.NotNull(found1);
Assert.Null(notFound1);
Assert.Null(notFound2);
Assert.Equal("Tester Doe", found1.Name);
}
}
}
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using Landmark.OLA.Models.Addresses.Enums;
using Landmark.OLA.Models.Residences;
namespace Landmark.OLA.Tests.TestData
{
public class TestAddresses
{
public static CurrentResidenceAddress GetValidAddress()
{
return new CurrentResidenceAddress
{
Address1 = "123 Main St",
City = "New Berlin",
State = StateOption.WI,
PostalCode = "53151",
Country = CountryOption.UnitedStates,
ResidenceType = ResidenceTypeOption.Own,
MonthsResided = 18,
MonthlyPayment = 100,
};
}
public static IEnumerable<Object[]> GetValidTestAddresses()
{
yield return new Object[] { GetValidAddress() };
}
public static IEnumerable<Object[]> GetInvalidTestAddresses()
{
var address1Empty = GetValidAddress();
address1Empty.Address1 = " ";
yield return new Object[] { address1Empty };
var address1TooLong = GetValidAddress();
address1TooLong.Address1 = new string('x', 45); //45 char string
yield return new Object[] { address1TooLong };
var address2TooLong = GetValidAddress();
address2TooLong.Address2 = new string('x', 45); //45 char string
yield return new Object[] { address2TooLong };
var cityTooLong = GetValidAddress();
cityTooLong.City = new string('x', 105); //105 char string
yield return new Object[] { cityTooLong };
var postalCodeTooLong = GetValidAddress();
postalCodeTooLong.PostalCode = new string('x', 10); //10 char string
yield return new Object[] { postalCodeTooLong };
var missingState = GetValidAddress();
missingState.State = null;
yield return new Object[] { missingState };
var missingAddress1 = GetValidAddress();
missingAddress1.Address1 = null;
yield return new Object[] { missingAddress1 };
var missingCity = GetValidAddress();
missingCity.City = null;
yield return new Object[] { missingCity };
var missingPostalCode = GetValidAddress();
missingPostalCode.PostalCode = null;
yield return new Object[] { missingPostalCode };
var missingResidenceType = GetValidAddress();
missingResidenceType.ResidenceType = null;
yield return new Object[] { missingResidenceType };
var missingMonthsResided = GetValidAddress();
missingMonthsResided.MonthsResided = null;
yield return new Object[] { missingMonthsResided };
}
}
}
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using Landmark.OLA.Models.Individuals;
using Landmark.OLA.Models.Individuals.Enums;
namespace Landmark.OLA.Tests.TestData
{
public class TestEmployers
{
private static Employer GetValidEmployer()
{
return new Employer
{
Name = "Test Employer",
Title = "QA",
WorkPhone = "9992245555",
Income = TestIncomes.GetValidEmploymentIncome(),
CurrentEmployer = false,
EmploymentType = EmploymentTypeOption.PartTime,
StartDate = new DateTime(2017, 10, 1),
};
}
public static IEnumerable<Object[]> GetValidTestEmployers()
{
yield return new Object[] { GetValidEmployer() };
}
public static IEnumerable<Object[]> GetInvalidTestEmployers()
{
var missingName = GetValidEmployer();
missingName.Name = null;
yield return new Object[] { missingName };
var invalidEmployerName = GetValidEmployer();
invalidEmployerName.Name+=".";
yield return new Object[] { invalidEmployerName };
}
}
}
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using Landmark.OLA.Models.Individuals;
using Landmark.OLA.Models.Individuals.Enums;
namespace Landmark.OLA.Tests.TestData
{
public class TestIncomes
{
private static Income GetValidIncome()
{
return new Income
{
IncomeTypeCD = IncomeType.Salary,
SourceName = "Salary",
AmountPerPeriod = 1000,
Frequency = Frequency.Monthly,
IncomeStatus = IncomeStatus.IncomeStatus_Included
};
}
public static Income GetValidEmploymentIncome()
{
return GetValidIncome();
}
public static IEnumerable<Object[]> GetValidTestIncomes()
{
yield return new Object[] { GetValidIncome() };
}
public static IEnumerable<Object[]> GetInvalidTestIncomes()
{
var missingSourceName = GetValidIncome();
missingSourceName.SourceName = null;
yield return new Object[] { missingSourceName };
}
}
}
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using Landmark.OLA.Models.Individuals;
using Landmark.OLA.Models.Individuals.Enums;
using Landmark.OLA.Tests.TestData;
namespace Landmark.OLA.Tests
{
public class TestIndividuals
{
private static Individual GetValidIndividual()
{
return new Individual
{
FirstName = "First",
LastName = "Last",
MiddleInitial = "M",
DOB = DateTime.Now,
SSN = "123456789",
Phone = "5551234567",
PhoneType = PhoneType.Home,
Email = "[email protected]",
IsMarried = true,
Address = TestAddresses.GetValidAddress(),
Language = LanguageOption.English,
};
}
public static IEnumerable<Object[]> GetValidTestIndividuals()
{
yield return new Object[] { GetValidIndividual() };
//Different but valid phone formatting
var phoneFormatting = GetValidIndividual();
phoneFormatting.Phone = "+1 (555) 123-4567 x123";
yield return new Object[] { phoneFormatting };
}
public static IEnumerable<Object[]> GetInvalidTestIndividuals()
{
var missingEmail = GetValidIndividual();
missingEmail.Email = null;
yield return new Object[] { missingEmail };
var missingDob = GetValidIndividual();
missingDob.DOB = null;
yield return new Object[] { missingDob };
var missingAddress = GetValidIndividual();
missingAddress.Address = null;
yield return new Object[] { missingAddress };
var badMI = GetValidIndividual();
badMI.MiddleInitial = "Name";
yield return new Object[] { badMI };
var missingPhoneType = GetValidIndividual();
missingPhoneType.PhoneType = null;
yield return new Object[] { missingPhoneType };
var invalidSssnChars = GetValidIndividual();
invalidSssnChars.SSN = "123-45-6789";
yield return new Object[] { invalidSssnChars };
}
}
}
@@ -0,0 +1,121 @@
{
"validLoans": [
{
"loanType": "V_Vehicle",
"note": "testing 2",
"primaryBorrower": {
"language": "English",
"firstName": "Joe",
"middleInitial": null,
"lastName": "TEST",
"dob": "01/01/1990",
"ssn": "123456789",
"phone": "1112223333",
"phoneType": "Home",
"secondaryPhone": null,
"secondaryPhoneType": null,
"email": "[email protected]",
"isMarried": false,
"address": {
"address1": "123 Main St",
"address2": "",
"city": "Milwaukee",
"state": "WI",
"postalCode": "53202",
"postalCodeExt": null,
"country": "UnitedStates",
"residenceType": "Own",
"monthsResided": 101,
"monthlyPayment": "500"
},
"previousAddresses": null,
"otherIncomes": [
{
"incomeTypeCD": "Other",
"sourceName": "IRA",
"frequency": "Annually",
"amountPerPeriod": "99999",
"incomeStatus": "IncomeStatus_Included"
}
],
"hasOptedOutTCPA": false,
"customerNumber": "0",
"employers": []
},
"purpose": "Purchase",
"requestedAmount": "5000",
"termLengthInMonths": "75",
"vehicle": {
"valuationType": "Manual",
"condition": "New",
"seller": "Dealer",
"type": "Automobile",
"year": "2030",
"mileage": "10",
"make": "Chevy",
"model": "Caprice classic",
"initialEstimatedValue": "50000"
}
},
{
"LoanType": "CC_CashBack",
"Purpose": "Other",
"RequestedAmount": "5000",
"PrimaryBorrower": {
}
},
{
"LoanType": "V_Vehicle",
"Purpose": "Purchase",
"TermLengthInMonths": "36",
"RequestedAmount": "5000",
"PrimaryBorrower": {},
"Vehicle": {
"Year": 0,
"Condition": "New",
"Type": "Automobile"
}
},
{
"LoanType": "P_Powersport",
"Purpose": "Purchase",
"TermLengthInMonths": "72",
"RequestedAmount": "8000",
"PrimaryBorrower": {},
"Vehicle": {
"ValuationType": "Manual",
"Condition": "Used",
"Type": "Snowmobile",
"Year": "2019",
"Make": "SKIDOO",
"Model": "MXZ",
"InitialEstimatedValue": "10500"
}
},
{
"LoanType": "V_Vehicle",
"Purpose": "Purchase",
"TermLengthInMonths": "36",
"RequestedAmount": "5000",
"PrimaryBorrower": {},
"Vehicle": {
"Year": 9999,
"Condition": "New",
"Type": "Automobile"
}
},
{
"LoanType": "V_Vehicle",
"Purpose": "Purchase",
"TermLengthInMonths": "36",
"RequestedAmount": "5000",
"PrimaryBorrower": {},
"Vehicle": {
"Year": 2010,
"Condition": "New",
"Type": "Automobile"
}
}
]
}
@@ -0,0 +1,45 @@
{
"vehicles": [
{
"Year": 0,
"Condition": "New",
"Type": "Automobile"
},
{
"Year": 9999,
"Condition": "New",
"Type": "Automobile"
},
{
"Year": 2009,
"Condition": "New",
"Type": "Automobile"
},
{
"Year": 2010,
"Condition": "New",
"Type": "Automobile"
},
{
"Year": 2018,
"Condition": "New",
"Type": "Automobile"
},
{
"Year": 2019,
"Condition": "New",
"Type": "Automobile"
},
{
"valuationType": "Manual",
"condition": "New",
"seller": "Dealer",
"type": "Automobile",
"year": "2030",
"mileage": "10",
"make": "Chevy",
"model": "Caprice classic",
"initialEstimatedValue": "50000"
}
]
}
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- additional settings used during the dotnet test execution step in the azure dev ops pipeline -->
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<CompanyNames>
<Exclude>
<CompanyName>.*microsoft.*</CompanyName>
</Exclude>
</CompanyNames>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>