public void TestAmericanFull() { var testResult = new NorthAmerican(DateTime.Now.AddYears(-36), Gender.Female, true, true); Assert.IsNotNull(testResult.GetMother()); Assert.AreNotEqual(0, testResult.GetMother().GetChildrenAt(null)); Assert.IsNotNull(testResult.GetWealthAt(null)); }
public void NorthAmericanEduTestsChild() { var amer = new NorthAmerican(DateTime.Now.AddYears(-9), Gender.Female); var testResult = new NorthAmericanEdu(amer); Assert.IsNotNull(testResult); Assert.IsNull(testResult.HighSchool); Assert.IsNull(testResult.College); }
public PersonalCreditScore(NorthAmerican american) { if (american == null) return; _american = american; //need this to stay same for object lifecycle so repeated calls return same result. FicoBaseValue = Etx.RandomValueInNormalDist(AVG_AMERICAN_FICO_SCORE, STD_DEV_FICO_SCORE); }
public void NorthAmericanEduTests() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testResult = new NorthAmericanEdu(amer); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.HighSchool); WriteLine(testResult.HighSchool); WriteLine(testResult.College); }
public void TestGetPaycheck() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer); System.Diagnostics.Debug.WriteLine(string.Join(" ", amer.Age, amer.MaritialStatus, amer.Education, amer.Race)); var testResult = testSubject.GetYearlyIncome(null,1.0); System.Diagnostics.Debug.WriteLine(testResult); Assert.IsNotNull(testResult); Assert.IsTrue(testResult.Amount > 0.0M); }
public void TestCreditCardCtor() { var testInput = new NorthAmerican(NoFuture.Rand.Domus.NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new VisaCc(testInput, DateTime.Today, null); Assert.IsNotNull(testSubject.Number); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.Number.Value)); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.CardHolderName)); Assert.IsFalse(string.IsNullOrWhiteSpace(testSubject.Cvv)); System.Diagnostics.Debug.WriteLine(testSubject.ToString()); }
public void TestCreateRandomAmericanOpes() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer); System.Diagnostics.Debug.WriteLine(string.Join(" ", amer.Age, amer.MaritialStatus, amer.Education, amer.Race)); testSubject.CreateRandomAmericanOpes(); Assert.IsTrue(testSubject.HomeDebt.Any()); Assert.IsTrue(testSubject.CheckingAccounts.Any()); Assert.IsTrue(testSubject.SavingAccounts.Any()); System.Diagnostics.Debug.WriteLine(testSubject.FinancialData.ToString()); }
public void TestGetMinPayment() { var testInput = new NorthAmerican(NoFuture.Rand.Domus.NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new CreditCardAccount(new VisaCc(testInput, new DateTime(2014,1,11), null), CreditCardAccount.DF_MIN_PMT_RATE, new Pecuniam(1800.0M)); testSubject.Pop(new DateTime(2014, 1, 11), new Pecuniam(63.32M)); testSubject.Pop(new DateTime(2014, 1, 11), new Pecuniam(7.54M)); testSubject.Pop(new DateTime(2014, 1, 12), new Pecuniam(139.47M)); testSubject.Pop(new DateTime(2014, 1, 12), new Pecuniam(2.38M)); testSubject.Pop(new DateTime(2014, 1, 14), new Pecuniam(57.89M)); testSubject.Pop(new DateTime(2014, 1, 14), new Pecuniam(10.09M)); testSubject.Pop(new DateTime(2014, 1, 15), new Pecuniam(7.78M)); testSubject.Pop(new DateTime(2014, 1, 15), new Pecuniam(52.13M)); testSubject.Pop(new DateTime(2014, 1, 15), new Pecuniam(22.95M)); testSubject.Pop(new DateTime(2014, 1, 16), new Pecuniam(47.59M)); testSubject.Pop(new DateTime(2014, 1, 17), new Pecuniam(703.65M)); testSubject.Pop(new DateTime(2014, 1, 17), new Pecuniam(32.11M)); testSubject.Pop(new DateTime(2014, 1, 17), new Pecuniam(12.83M)); testSubject.Pop(new DateTime(2014, 1, 18), new Pecuniam(60.83M)); testSubject.Pop(new DateTime(2014, 1, 20), new Pecuniam(57.64M)); testSubject.Pop(new DateTime(2014, 1, 20), new Pecuniam(49.07M)); testSubject.Pop(new DateTime(2014, 1, 21), new Pecuniam(3.55M)); testSubject.Pop(new DateTime(2014, 1, 24), new Pecuniam(6.94M)); testSubject.Pop(new DateTime(2014, 1, 25), new Pecuniam(6.94M)); testSubject.Pop(new DateTime(2014, 1, 27), new Pecuniam(10.61M)); testSubject.Pop(new DateTime(2014, 1, 27), new Pecuniam(50.73M)); testSubject.Pop(new DateTime(2014, 1, 28), new Pecuniam(8.32M)); var testResult = testSubject.GetMinPayment(new DateTime(2014, 1, 28)); Assert.AreEqual(-17.68M, testResult.Amount); System.Diagnostics.Debug.WriteLine(testResult); System.Diagnostics.Debug.WriteLine(testSubject.GetValueAt(new DateTime(2014, 1, 28))); testSubject.Pop(new DateTime(2014, 1, 30), new Pecuniam(61.28M)); testSubject.Pop(new DateTime(2014, 2, 1), new Pecuniam(23.11M)); testSubject.Pop(new DateTime(2014, 2, 2), new Pecuniam(9.83M)); testSubject.Pop(new DateTime(2014, 2, 3), new Pecuniam(8.53M)); testSubject.Pop(new DateTime(2014, 2, 3), new Pecuniam(2.09M)); testSubject.Pop(new DateTime(2014, 2, 4), new Pecuniam(7.79M)); testSubject.Pop(new DateTime(2014, 2, 6), new Pecuniam(47.24M)); testSubject.Pop(new DateTime(2014, 2, 7), new Pecuniam(55.95M)); testSubject.Pop(new DateTime(2014, 2, 7), new Pecuniam(30.1M)); testSubject.Pop(new DateTime(2014, 2, 8), new Pecuniam(37.39M)); testSubject.Pop(new DateTime(2014, 2, 10), new Pecuniam(3.91M)); }
public void TestGetRandomCcDebt() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer); testSubject.AddSingleCcDebt(); Assert.IsTrue(testSubject.CreditCardDebt.Any()); var testResult = testSubject.CreditCardDebt.First() as CreditCardAccount; Assert.IsNotNull(testResult); System.Diagnostics.Debug.WriteLine(testResult.Cc.CardHolderSince); System.Diagnostics.Debug.WriteLine(testResult.Max); System.Diagnostics.Debug.WriteLine(testResult.TradeLine.Balance.ToString()); }
public void AmericanTests() { var testDob = new DateTime(1974,5,6); var testResult = new NorthAmerican(testDob, Gender.Female); Assert.IsNotNull(testResult); Assert.AreNotEqual(Gender.Unknown, testResult.MyGender); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.LastName)); Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.FirstName)); Assert.IsNotNull(testResult.BirthCert); Assert.IsNotNull(testResult.Address); Assert.IsNotNull(testResult.Address.HomeCityArea); Assert.IsInstanceOfType(testResult.Address.HomeCityArea, typeof(UsCityStateZip)); Assert.IsNotNull(((UsCityStateZip)testResult.Address.HomeCityArea).State); Assert.IsNotNull(testResult.DriversLicense); //Assert.IsNotNull(testResult.GetMother()); //Assert.AreNotEqual(0, testResult.GetMother().GetChildrenAt(null)); }
public void TestGetRandomBankAccount() { var p = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testResult = CheckingAccount.GetRandomCheckingAcct(p); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Id); System.Diagnostics.Debug.WriteLine(testResult.Id.Value); testResult = CheckingAccount.GetRandomCheckingAcct(p); Assert.IsNotNull(testResult.Id); Assert.IsNotNull(testResult.Bank); System.Diagnostics.Debug.WriteLine(testResult.Id.Value); System.Diagnostics.Debug.WriteLine(testResult.Bank.Name); }
public DriversLicense IssueNewLicense(NorthAmerican amer, DateTime? issuedDate = null) { if(format == null || !format.Any() || IssuingState == null) throw new ItsDeadJim("Cannot issue a DL with having a DL Format and IssuingState"); if (amer == null) return new DriversLicense(format, IssuingState); var dl = new DriversLicense(format, IssuingState) { Dob = amer.BirthCert.DateOfBirth, FullLegalName = string.Join(" ", amer.FirstName.ToUpper(), amer.MiddleName.ToUpper(), amer.LastName.ToUpper()), Gender = amer.MyGender, PrincipalResidence = amer.Address.ToString(), IssuedDate = issuedDate ?? Etx.Date(-5, DateTime.Today) }; return dl; }
/// <summary> /// Creates random transaction history. /// </summary> /// <param name="american"></param> /// <param name="isRenting">Optional, force the generated instance as renting (instead of mortgage)</param> public NorthAmericanWealth(NorthAmerican american, bool isRenting = false) { if(american == null) throw new ArgumentNullException(nameof(american)); _amer = american; var usCityArea = _amer.Address.HomeCityArea as UsCityStateZip; if (usCityArea == null) return; CreditScore = new PersonalCreditScore(american); //determine if renting or own _isRenting = isRenting || GetIsLeaseResidence(usCityArea); var edu = _amer.Education?.EduLevel ?? (OccidentalEdu.HighSchool | OccidentalEdu.Grad); var race = _amer.Race; var region = usCityArea.State?.GetStateData()?.Region ?? AmericanRegion.Midwest; _homeDebtFactor = GetFactor(FactorTables.HomeDebt, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _vehicleDebtFactor = GetFactor(FactorTables.VehicleDebt, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _ccDebtFactor = GetFactor(FactorTables.CreditCardDebt, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _savingAcctFactor = GetFactor(FactorTables.SavingsAccount, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _checkingAcctFactor = GetFactor(FactorTables.CheckingAccount, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _netWorthFactor = GetFactor(FactorTables.NetWorth, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _homeEquityFactor = GetFactor(FactorTables.HomeEquity, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); _vehicleEquityFactor = GetFactor(FactorTables.VehicleEquity, edu, race, region, _amer.Age, _amer.MyGender, _amer.MaritialStatus); var payBase = new Pecuniam(2000); Func<Pecuniam, double> calcMonthlyPay = pecuniam => Math.Round((double)GetYearlyIncome(pecuniam, _netWorthFactor).Amount / 12, 2); Paycheck = Math.Round(calcMonthlyPay(payBase) / 2, 2).ToPecuniam(); }
/// <summary> /// Utility method to dump all the spouse data on an instance of <see cref="NorthAmerican"/> /// </summary> /// <param name="nAmer"></param> /// <returns></returns> public static List<Spouse> DumpAllSpouses(NorthAmerican nAmer) { return nAmer._spouses.ToList(); }
public void TestNorthAmericanWithFamily() { var testResult = new NoFuture.Rand.Domus.NorthAmerican(DateTime.Now.AddYears(-40), Gender.Female, true, false ); Assert.IsNotNull(testResult.GetMother()); Assert.IsNotNull(testResult.GetFather()); }
/// <summary> /// Sets <see cref="thisPerson"/> home-related data to the same values of <see cref="livesWithThisOne"/> /// </summary> /// <param name="thisPerson"></param> /// <param name="livesWithThisOne"></param> public static void SetNAmerCohabitants(NorthAmerican thisPerson, NorthAmerican livesWithThisOne) { if (thisPerson == null || livesWithThisOne == null) return; var addrMatchTo = livesWithThisOne.GetAddressAt(null); if (addrMatchTo == null) return; thisPerson.UpsertAddress(addrMatchTo); thisPerson._phoneNumbers.Clear(); if (livesWithThisOne._phoneNumbers.Any(p => p.Item1 == KindsOfLabels.Home)) { thisPerson._phoneNumbers.Add(livesWithThisOne._phoneNumbers.First(p => p.Item1 == KindsOfLabels.Home)); } if (thisPerson.GetAgeAt(null) >= 12 && !String.IsNullOrWhiteSpace(addrMatchTo.HomeCityArea?.GetPostalCodePrefix())) thisPerson._phoneNumbers.Add(new Tuple<KindsOfLabels, NorthAmericanPhone>(KindsOfLabels.Mobile, Phone.American(addrMatchTo.HomeCityArea.GetPostalCodePrefix()))); }
/// <summary> /// Returns a new <see cref="IPerson"/> representing a /// parent of the specified <see cref="gender"/> having a realistic age /// from the <see cref="childDob"/>. /// </summary> /// <param name="childDob"></param> /// <param name="eq"></param> /// <param name="gender"></param> /// <returns></returns> public static IPerson SolveForParent(DateTime childDob, LinearEquation eq, Gender gender) { //move to a date 1 - 6 years prior the Person's dob var dtPm = childDob.AddYears(-1 * Etx.IntNumber(1, 6)).AddDays(Etx.IntNumber(1, 360)); //calc the age of marriable person at this time var avgAgeCouldMarry = eq.SolveForY(dtPm.ToDouble()); //move the adjusted child-dob date back by calc'ed years var parentDob = dtPm.AddYears(Convert.ToInt32(Math.Round(avgAgeCouldMarry, 0))*-1); var aParent = new NorthAmerican(parentDob, gender, false, false); return aParent; }
public void TestGetRandomHomeLoan() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer); testSubject.AddMortgage(); var homeLoan = testSubject.HomeDebt.FirstOrDefault() as FixedRateLoan; Assert.IsNotNull(homeLoan); System.Diagnostics.Debug.WriteLine(homeLoan.TradeLine.Balance.ToString()); }
public void TestResolveParents() { var testResult = new NoFuture.Rand.Domus.NorthAmerican(DateTime.Now.AddYears(-40), Gender.Female); Assert.IsNull(testResult.GetMother()); Assert.IsNull(testResult.GetFather()); testResult.ResolveParents(); Assert.IsNotNull(testResult.GetMother()); Assert.IsNotNull(testResult.GetFather()); }
public void TestGetMaritalStatus() { var testSubject = new NoFuture.Rand.Domus.NorthAmerican(DateTime.Now.AddYears(-40), Gender.Female); var testResult = testSubject.GetMaritalStatusAt(null); Assert.AreNotEqual(MaritialStatus.Unknown, testResult); WriteLine(testResult); testResult = testSubject.GetMaritalStatusAt(DateTime.Now.AddYears(-10)); Assert.AreNotEqual(MaritialStatus.Unknown, testResult); WriteLine(testResult); }
public void TestIsValidDobOfChild() { var testPerson = new NorthAmerican(new DateTime(1955,6,20), Gender.Female, false, false); testPerson._children.Add(new Child(new NorthAmerican(new DateTime(1976, 10, 2), Gender.Female, false, false))); testPerson._children.Add(new Child(new NorthAmerican(new DateTime(1986, 3, 11), Gender.Female, false, false))); testPerson._children.Add(new Child(new NorthAmerican(new DateTime(1982, 12, 30), Gender.Female, false, false))); var testDob = new DateTime(1985, 9, 10);//conception ~ 12/4/1984 var testResult = testPerson.IsValidDobOfChild(testDob); //invalid: dob during prev preg Assert.IsFalse(testResult); testDob = testDob.AddDays(313);//conception ~ 10/13/1985, dob ~ 7/20/1986 //invalid: conception during prev preg testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsFalse(testResult); testDob = testDob.AddDays(313);//conception ~ 8/22/1986, dob 5/29/1987 //valid: conception ~ 5 months after prev birth testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsTrue(testResult); testPerson = new NorthAmerican(new DateTime(1982,4,13), Gender.Female, false, false); testPerson._children.Add(new Child(new NorthAmerican(new DateTime(2007, 8, 30), Gender.Male))); testPerson._children.Add(new Child(new NorthAmerican(new DateTime(2009, 12, 20), Gender.Female))); testDob = new DateTime(2009,3,6); Assert.IsFalse(testPerson.IsValidDobOfChild(testDob)); testDob = testDob.AddDays(280 + 28); Assert.IsFalse(testPerson.IsValidDobOfChild(testDob)); testDob = testDob.AddDays(280 + 28); testResult = testPerson.IsValidDobOfChild(testDob); Assert.IsTrue(testResult); WriteLine(testDob); }
public void TestGetSpouseAt() { //test with full timestamps var firstMarriageDate = new DateTime(DateTime.Today.Year - 15, 8, 8, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); var firstDivorceDate = new DateTime(DateTime.Today.Year - 3, 2, 14, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); var secondMarriageDate = new DateTime((DateTime.Today.Year - 1), 12, 23, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); var testPerson = new NorthAmerican(new DateTime((DateTime.Today.Year - 42), 6, 20), Gender.Female); var firstSpouse = new NorthAmerican(new DateTime((DateTime.Today.Year - 46), 4, 4), Gender.Male); testPerson.AddNewSpouseToList(firstSpouse, firstMarriageDate, firstDivorceDate); var secondSpouse = new NorthAmerican(new DateTime((DateTime.Today.Year - 43), 12, 16), Gender.Male); testPerson.AddNewSpouseToList(secondSpouse, secondMarriageDate); //expect true when on day-of-wedding var testResult = testPerson.GetSpouseAt(firstMarriageDate); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(firstSpouse)); //expect false for day of separated testResult = testPerson.GetSpouseAt(firstDivorceDate); Assert.IsNull(testResult); //expect true any time between for (var i = firstMarriageDate.Year + 1; i < firstDivorceDate.Year; i++) { for (var j = 1; j < 13; j++) { testResult = testPerson.GetSpouseAt(new DateTime(i, j, 8)); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(firstSpouse)); } } //expect false day directly before second marriage testResult = testPerson.GetSpouseAt(secondMarriageDate.Date.AddMilliseconds(-1)); Assert.IsNull(testResult); testResult = testPerson.GetSpouseAt(secondMarriageDate.Date); Assert.IsNotNull(testResult); Assert.IsNotNull(testResult.Est); Assert.IsTrue(testResult.Est.Equals(secondSpouse)); }
public void TestGetRandomRent() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer, true); testSubject.AddRent(); var rent = testSubject.HomeDebt.FirstOrDefault() as Rent; Assert.IsNotNull(rent); System.Diagnostics.Debug.WriteLine(rent.TradeLine.Balance.ToString()); }
public void TestGetRandomVehicle() { var amer = new NorthAmerican(NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new NorthAmericanWealth(amer); System.Diagnostics.Debug.WriteLine(string.Join(" ", amer.Age, amer.MaritialStatus, amer.Education, amer.Race)); var testResult = testSubject.AddVehicleLoan(); Assert.IsNotNull(testResult); if (testSubject.VehicleDebt.Any()) { var testResultSfrl = testSubject.VehicleDebt.First() as NoFuture.Rand.Data.Sp.SecuredFixedRateLoan; Assert.IsNotNull(testResultSfrl); System.Diagnostics.Debug.WriteLine(testResultSfrl.Description); Assert.IsNotNull( testResultSfrl.PropertyId); } }
/// <summary> /// Add a random <see cref="IPerson"/> to the Children collection. /// </summary> /// <param name="myChildDob"> /// This will be adusted up by when the Birth Date would occur during the pregnancy /// of a sibling unless it is the exact same date (twins). /// </param> protected internal void AddNewChildToList(DateTime myChildDob) { if (MyGender == Gender.Male) return; var dt = DateTime.Now; DateTime dtOut; if (IsTwin(myChildDob, out dtOut) && DateTime.Compare(dtOut, DateTime.MinValue) != 0) { myChildDob = dtOut; } else { //need to move Dob based on timing of siblings and biology of mother while (!IsValidDobOfChild(myChildDob)) { myChildDob = myChildDob.AddDays(PREG_DAYS + MS_DAYS); } } var myChildeAge = CalcAge(myChildDob, dt); var myChildGender = Etx.CoinToss ? Gender.Female : Gender.Male; var isChildAdult = myChildeAge >= GetMyHomeStatesAgeOfMajority(); //look for spouse at and around Dob var spouseAtChildDob = GetSpouseAt(myChildDob) ?? GetSpouseAt(myChildDob.AddDays(-1*(PREG_DAYS + MS_DAYS))) ?? GetSpouseAt(myChildDob.AddDays(PREG_DAYS + MS_DAYS)); var childLastName = string.IsNullOrWhiteSpace(spouseAtChildDob?.Est?.LastName) || spouseAtChildDob.Est?.MyGender == Gender.Female ? LastName : spouseAtChildDob.Est?.LastName; var nAmerChild = new NorthAmerican(myChildDob, myChildGender, this, spouseAtChildDob?.Est) { LastName = childLastName }; //child has ref to father, father needs ref to child var nAmerFather = spouseAtChildDob?.Est as NorthAmerican; if (nAmerFather != null && nAmerFather.MyGender == Gender.Male && nAmerFather.Children.All(x => !nAmerChild.Equals(x.Est))) { nAmerFather._children.Add(new Child(nAmerChild)); } //resolve spouse, no grand-children if (isChildAdult) { nAmerChild.ResolveSpouse(NAmerUtil.GetMaritialStatus(myChildDob, myChildGender)); nAmerChild.AlignCohabitantsHomeDataAt(DateTime.Now, nAmerChild.GetAddressAt(null)); } _children.Add(new Child(nAmerChild)); }
public void TestMakePayment() { var testInput = new NorthAmerican(NoFuture.Rand.Domus.NAmerUtil.GetWorkingAdultBirthDate(), Gender.Female); var testSubject = new CreditCardAccount(new VisaCc(testInput, DateTime.Today.AddDays(-15), null), CreditCardAccount.DF_MIN_PMT_RATE, new Pecuniam(1800.0M)); }