using System; using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities; using LCU.Library.Internal.IncentiveApiModels.Enums; using NUnit.Framework; namespace Application.UnitTests.Models.ExternalActivity { public class ExternalActivityTests { private NewLoanSaleActivity externalActivity = new NewLoanSaleActivity(); [SetUp] public void SetUp() { externalActivity.ActivityNbr = 100; externalActivity.ActivityDateTime = DateTime.Parse("2021-09-28T21:32:38"); externalActivity.SubjectAccountNbr = 555; externalActivity.OriginatingPersonNbr = 10; externalActivity.ActivityTypeCode = "ADAC"; externalActivity.MajorAccountType = "CNS"; externalActivity.MinorAccountType = "DV01"; externalActivity.AssociateFirst = "Bruce"; externalActivity.AssociateMiddleInit = null; externalActivity.AssociateLast = "Willis"; externalActivity.TaxPersonNbr = "1258"; externalActivity.TaxOrgNbr = null; externalActivity.AccountContractDate = DateTime.Parse("2021-09-28T00:00:00"); externalActivity.CurrentAccountStatus = "ACT"; externalActivity.BranchOrgNbr = 1119; externalActivity.BranchOrgName = "Oak Creek Branch"; externalActivity.EmployeeEmail = "email@test.com"; externalActivity.LoanSourceCode = "NEW"; externalActivity.LoanAmount = 23000; externalActivity.DebtProtectionEffectiveDate = DateTime.Parse("2021-09-29T00:00:00"); externalActivity.YoungestBirthdateOnLoan = DateTime.Parse("1999-04-01T00:00:00"); externalActivity.HasOrgRoles = 0; } [TestCase("BE21", 0, null, false, false)] [TestCase("DV01", 1, null, false, true)] [TestCase("DV01", 0, "12345", false, true)] [TestCase("DV02", 0, null, true, true)] [TestCase("DV03", 0, null, true, true)] [TestCase("DV04", 0, null, true, true)] [TestCase("DV05", 0, null, true, true)] [TestCase("DV06", 0, null, true, true)] [TestCase("DV07", 0, null, true, true)] [TestCase("DV08", 0, null, true, true)] [TestCase("SC01", 0, null, true, false)] [TestCase("SC02", 0, null, true, false)] [TestCase("SG01", 0, null, true, false)] [TestCase("NotReal", 0, null, false, true)] [TestCase("FE01", 0, null, false, false)] public void ExternalLoanSaleActivity_IsDebtProtectionEligible_OK(string minorAccountType, int hasOrgRoles, string taxOrgNbr, bool result, bool isGap) { externalActivity.MinorAccountType = minorAccountType; externalActivity.TaxOrgNbr = taxOrgNbr; externalActivity.HasOrgRoles = hasOrgRoles; var mapped = externalActivity.MapToActivity(); Assert.AreEqual(result, mapped.Detail.IsDebtProtectionEligible); Assert.AreEqual(isGap, mapped.Detail.IsGapInsuranceEligible); } [TestCase("FE01", Product.Mortgage, false)] [TestCase("FE02", Product.Mortgage, false)] [TestCase("FLML", Product.Mortgage, false)] [TestCase("MF01", Product.Mortgage, false)] [TestCase("FNMA", Product.FirstMortgageReferral, false)] [TestCase("fnma", Product.FirstMortgageReferral, false)] [TestCase("FRML", Product.FirstMortgageReferral, false)] [TestCase("frMl", Product.FirstMortgageReferral, false)] [TestCase("mJ30", Product.FirstMortgageReferral, false)] [TestCase("MJ30", Product.FirstMortgageReferral, false)] [TestCase("DL01",Product.Vehicle, true)] [TestCase("DV07",Product.Vehicle, true)] [TestCase("DV08",Product.Vehicle, true)] [TestCase("DL09",Product.Vehicle, true)] [TestCase("DV02",Product.Vehicle, true)] [TestCase("DV03",Product.Vehicle, true)] [TestCase("DV04",Product.Vehicle, true)] [TestCase("DV05",Product.Vehicle, true)] [TestCase("DV06",Product.Vehicle, true)] [TestCase("DL08",Product.Vehicle, true)] [TestCase("DV01",Product.Vehicle, true)] [TestCase("DL13",Product.Vehicle, true)] [TestCase("DL14",Product.Vehicle, true)] [TestCase("DL16",Product.Vehicle, true)] [TestCase("DL10",Product.Vehicle, true)] [TestCase("DL12",Product.Vehicle, true)] [TestCase("DL11",Product.Vehicle, true)] [TestCase("DL07",Product.Vehicle, true)] [TestCase("DL06",Product.Vehicle, true)] [TestCase("SC01",Product.DebtProtectionEligibleLoan, false)] [TestCase("SC02",Product.DebtProtectionEligibleLoan, false)] [TestCase("SG01",Product.DebtProtectionEligibleLoan, false)] public void NewLoanActivity_MapActivity_Product(string minorAccountType, Product expectedProduct, bool isGap) { externalActivity.MinorAccountType = minorAccountType; var mapped = externalActivity.MapToActivity(); Assert.AreEqual(expectedProduct, mapped.Product); Assert.AreEqual(isGap, externalActivity.IsGapInsuranceEligible()); } [TestCase("CC Balance Transfer", Product.CreditCardBalanceTransfer, 0)] [TestCase("ATM Card", Product.ATMCard, 0)] [TestCase("Check Card Referral", Product.CheckCard, 0)] [TestCase("Checking Referral", Product.NewChecking, 0)] [TestCase("Mortgage Referral", Product.Mortgage, 0)] [TestCase("Direct Deposit", Product.DirectDeposit, 0)] [TestCase("LIC Referral", Product.LIC, 1)] [TestCase("First Mortgage Referral", Product.FirstMortgageReferral, 0)] [TestCase("eStatement Referral", Product.eStatement, 0)] public void NewActivityManagerReferral_MapActivity_Product(string campaign, Product expectedProduct, int isFinalStation) { var amr = new NewActivityManagerReferral(); amr.Campaign = campaign; amr.IsFinalStation = isFinalStation; var mapped = amr.MapToActivity(); Assert.AreEqual(expectedProduct, mapped.Product); } [TestCase("ATM", Product.ATMCard)] [TestCase("DB01", Product.CheckCard)] public void NewCardSaleActivity_MapActivity_Product(string cardType, Product expectedProduct) { var amr = new NewAtmCheckCardActivity(); amr.CardType = cardType; var mapped = amr.MapToActivity(); Assert.AreEqual(expectedProduct, mapped.Product); } [Test] public void ExternalLoanSaleActivity_IsDebtProtectionEligible_AgeCalc_OK() { externalActivity.YoungestBirthdateOnLoan = DateTime.Now.AddYears(-70).AddDays(-1); var mapped = externalActivity.MapToActivity(); Assert.AreEqual(false, mapped.Detail.IsDebtProtectionEligible); externalActivity.YoungestBirthdateOnLoan = DateTime.Now.AddYears(-68).AddDays(-1); mapped = externalActivity.MapToActivity(); Assert.AreEqual(true, mapped.Detail.IsDebtProtectionEligible); externalActivity.YoungestBirthdateOnLoan = DateTime.Now.AddYears(-22).AddDays(-1); mapped = externalActivity.MapToActivity(); Assert.AreEqual(true, mapped.Detail.IsDebtProtectionEligible); } } }