Esempio n. 1
0
        public void TestMakePayment()
        {
            var testInput   = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female);
            var testSubject = new CreditCardAccount(new VisaCc(testInput, DateTime.Today.AddDays(-15), null), CreditCardAccount.DF_MIN_PMT_RATE, new Pecuniam(1800.0M));

            Assert.IsTrue(testSubject.Max == new Pecuniam(1800.0M));
        }
Esempio n. 2
0
        public void TestNorthAmericanWithFamily()
        {
            var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female, true);

            Assert.IsNotNull(testResult.GetBiologicalMother());
            Assert.IsNotNull(testResult.GetBiologicalFather());
        }
Esempio n. 3
0
        public void TestAmericanFull()
        {
            var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-36), Gender.Female, true);

            Assert.IsNotNull(testResult.GetBiologicalMother());
            Assert.AreNotEqual(0, testResult.GetBiologicalMother().GetChildrenAt(null));
        }
Esempio n. 4
0
        public void TestAddParent()
        {
            var testMother = American.RandomAmerican(new DateTime(1970, 1, 1), Gender.Female);
            var testChild  =
                American.RandomAmerican(testMother.BirthCert.DateOfBirth.AddYears(25).AddDays(28), Gender.Female);

            testChild.AddParent(testMother, KindsOfNames.Biological | KindsOfNames.Mother);

            Assert.AreEqual(1, testChild.Parents.Count());

            var testResult =
                testChild.Parents.FirstOrDefault(c => c.AnyNames(k => k == (KindsOfNames.Biological | KindsOfNames.Mother)));

            Assert.IsNotNull(testResult);
            Assert.AreEqual(testMother, testResult.Est);

            //nothing changes
            testChild.AddParent(testMother, KindsOfNames.Biological | KindsOfNames.Mother);
            testResult =
                testChild.Parents.FirstOrDefault(c => c.AnyNames(k => k == (KindsOfNames.Biological | KindsOfNames.Mother)));
            Assert.IsNotNull(testResult);
            Assert.AreEqual(testMother, testResult.Est);

            //adding a Parent does not add a child
            Assert.AreEqual(0, testResult.Est.Children.Count());

            //cannot add when biological limits are exceeded
            testMother = American.RandomAmerican(new DateTime(1993, 1, 1), Gender.Female);
            testChild  =
                American.RandomAmerican(new DateTime(1996, 1, 1), Gender.Female);

            testChild.AddParent(testMother, KindsOfNames.Mother | KindsOfNames.Biological);
            Assert.AreEqual(0, testChild.Parents.Count());
        }
Esempio n. 5
0
        public void TestGetParent()
        {
            var testSubject = American.RandomAmerican();

            Assert.IsNotNull(testSubject.Parents);
            Assert.AreNotEqual(0, testSubject.Parents.Count());
        }
Esempio n. 6
0
        public void TestGetNorthAmericanEdu()
        {
            var testSubject = American.RandomAmerican();
            var testEdu     = testSubject.GetEducationAt(null);

            Assert.IsNotNull(testEdu);

            Console.WriteLine(testEdu);
        }
Esempio n. 7
0
        public void TestIsPin()
        {
            var testSubject = new CheckingAccount("ABC", DateTime.Today.AddDays(-65),
                                                  new Tuple <ICreditCard, string>(
                                                      CreditCard.RandomCreditCard(American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female)),
                                                      "8745"));

            Assert.IsTrue(testSubject.IsPin("8745"));
        }
Esempio n. 8
0
        public void NorthAmericanEduTests()
        {
            var amer       = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female);
            var testResult = amer.GetRandomEducation();

            Assert.IsNotNull(testResult);
            Assert.IsNotNull(testResult.HighSchool);
            Console.WriteLine(testResult.HighSchool);
            Console.WriteLine(testResult.College);
        }
Esempio n. 9
0
        public void TestResolveParents()
        {
            var testResult = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female);

            Assert.IsNull(testResult.GetBiologicalMother());
            Assert.IsNull(testResult.GetBiologicalFather());
            testResult.ResolveParents();
            Assert.IsNotNull(testResult.GetBiologicalMother());
            Assert.IsNotNull(testResult.GetBiologicalFather());
        }
Esempio n. 10
0
        public void AmericanTests()
        {
            var testDob    = new DateTime(1974, 5, 6);
            var testResult = American.RandomAmerican(testDob, Gender.Female);

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(Gender.Unknown, testResult.Gender);
            Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.LastName));
            Assert.IsFalse(string.IsNullOrWhiteSpace(testResult.FirstName));
            Assert.IsNotNull(testResult.BirthCert);
        }
Esempio n. 11
0
        public void TestToData()
        {
            var testSubject = American.RandomAmerican(DateTime.UtcNow.AddYears(-36), Gender.Female, true);
            var testResult  = testSubject.ToData(KindsOfTextCase.Kabab);

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Count);
            foreach (var tr in testResult.Keys)
            {
                Console.WriteLine($"{tr}, {testResult[tr]}");
            }
        }
Esempio n. 12
0
        public void TestCreditCardCtor()
        {
            var testInput   = American.RandomAmerican(Etx.RandomAdultBirthDate(), 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());
        }
Esempio n. 13
0
        public void TestGetSpouseAt()
        {
            //test with full timestamps
            var firstMarriageDate = new DateTime(DateTime.Today.Year - 15, 8, 8, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute,
                                                 DateTime.UtcNow.Second);
            var firstDivorceDate = new DateTime(DateTime.Today.Year - 3, 2, 14, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute,
                                                DateTime.UtcNow.Second);
            var secondMarriageDate = new DateTime((DateTime.Today.Year - 1), 12, 23, DateTime.UtcNow.Hour, DateTime.UtcNow.Minute,
                                                  DateTime.UtcNow.Second);


            var testPerson  = American.RandomAmerican(new DateTime((DateTime.Today.Year - 42), 6, 20), Gender.Female);
            var firstSpouse = American.RandomAmerican(new DateTime((DateTime.Today.Year - 46), 4, 4), Gender.Male);

            testPerson.AddSpouse(firstSpouse, firstMarriageDate, firstDivorceDate);

            var secondSpouse = American.RandomAmerican(new DateTime((DateTime.Today.Year - 43), 12, 16), Gender.Male);

            testPerson.AddSpouse(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));
        }
Esempio n. 14
0
        public void TestGetRandomMax()
        {
            var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female);

            var testSubject = new PersonalCreditScore(testInput.BirthCert.DateOfBirth)
            {
                OpennessZscore          = testInput.Personality?.Openness?.Value?.Zscore ?? 0D,
                ConscientiousnessZscore = testInput.Personality?.Conscientiousness?.Value?.Zscore ?? 0D
            };
            var testResult = testSubject.GetRandomMax(null);

            Debug.WriteLine(testResult);
        }
Esempio n. 15
0
        public void TestGetRandomInterestRate()
        {
            var testInput = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female);

            var testSubject = new PersonalCreditScore(testInput.BirthCert.DateOfBirth)
            {
                OpennessZscore          = testInput.Personality?.Openness?.Value?.Zscore ?? 0D,
                ConscientiousnessZscore = testInput.Personality?.Conscientiousness?.Value?.Zscore ?? 0D
            };

            Debug.WriteLine(testSubject.GetScore(new DateTime(DateTime.Today.Year, 1, 1)));
            var testResult = testSubject.GetRandomInterestRate(new DateTime(DateTime.Today.Year, 1, 1));

            Assert.IsTrue(testResult > 3.0D);
            Debug.WriteLine(testResult);
        }
Esempio n. 16
0
        public void TestGetMaritalStatus()
        {
            var testSubject = American.RandomAmerican(DateTime.UtcNow.AddYears(-40), Gender.Female);

            var testResult = testSubject.GetMaritalStatusAt(null);

            Assert.AreNotEqual(MaritalStatus.Unknown, testResult);

            Console.WriteLine(testResult);

            testResult = testSubject.GetMaritalStatusAt(DateTime.UtcNow.AddYears(-10));

            Assert.AreNotEqual(MaritalStatus.Unknown, testResult);

            Console.WriteLine(testResult);
        }
Esempio n. 17
0
        public void TestGetRandomBankAccount()
        {
            var p          = American.RandomAmerican(Etx.RandomAdultBirthDate(), Gender.Female);
            var testResult = DepositAccount.RandomCheckingAccount(p);

            Assert.IsNotNull(testResult);

            Assert.IsNotNull(testResult.Id);

            System.Diagnostics.Debug.WriteLine(testResult.Id.Value);


            testResult = DepositAccount.RandomCheckingAccount(p);
            Assert.IsNotNull(testResult.Id);

            System.Diagnostics.Debug.WriteLine(testResult.Id.Value);
        }
Esempio n. 18
0
        public void TestGetMinPayment()
        {
            var testInput   = American.RandomAmerican(Etx.RandomAdultBirthDate(), 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.MakePurchase(new DateTime(2014, 1, 11), new Pecuniam(63.32M));
            testSubject.MakePurchase(new DateTime(2014, 1, 11), new Pecuniam(7.54M));
            testSubject.MakePurchase(new DateTime(2014, 1, 12), new Pecuniam(139.47M));
            testSubject.MakePurchase(new DateTime(2014, 1, 12), new Pecuniam(2.38M));
            testSubject.MakePurchase(new DateTime(2014, 1, 14), new Pecuniam(57.89M));
            testSubject.MakePurchase(new DateTime(2014, 1, 14), new Pecuniam(10.09M));
            testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(7.78M));
            testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(52.13M));
            testSubject.MakePurchase(new DateTime(2014, 1, 15), new Pecuniam(22.95M));
            testSubject.MakePurchase(new DateTime(2014, 1, 16), new Pecuniam(47.59M));
            testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(703.65M));
            testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(32.11M));
            testSubject.MakePurchase(new DateTime(2014, 1, 17), new Pecuniam(12.83M));
            testSubject.MakePurchase(new DateTime(2014, 1, 18), new Pecuniam(60.83M));
            testSubject.MakePurchase(new DateTime(2014, 1, 20), new Pecuniam(57.64M));
            testSubject.MakePurchase(new DateTime(2014, 1, 20), new Pecuniam(49.07M));
            testSubject.MakePurchase(new DateTime(2014, 1, 21), new Pecuniam(3.55M));
            testSubject.MakePurchase(new DateTime(2014, 1, 24), new Pecuniam(6.94M));
            testSubject.MakePurchase(new DateTime(2014, 1, 25), new Pecuniam(6.94M));
            testSubject.MakePurchase(new DateTime(2014, 1, 27), new Pecuniam(10.61M));
            testSubject.MakePurchase(new DateTime(2014, 1, 27), new Pecuniam(50.73M));
            testSubject.MakePurchase(new DateTime(2014, 1, 28), new Pecuniam(8.32M));

            var testResult = testSubject.GetMinPayment(new DateTime(2014, 1, 28));

            Assert.AreEqual(-17.58M, testResult.Amount);
            Console.WriteLine(testResult);
            Console.WriteLine(testSubject.GetValueAt(new DateTime(2014, 1, 28)));

            testSubject.MakePurchase(new DateTime(2014, 1, 30), new Pecuniam(61.28M));
            testSubject.MakePurchase(new DateTime(2014, 2, 1), new Pecuniam(23.11M));
            testSubject.MakePurchase(new DateTime(2014, 2, 2), new Pecuniam(9.83M));
            testSubject.MakePurchase(new DateTime(2014, 2, 3), new Pecuniam(8.53M));
            testSubject.MakePurchase(new DateTime(2014, 2, 3), new Pecuniam(2.09M));
            testSubject.MakePurchase(new DateTime(2014, 2, 4), new Pecuniam(7.79M));
            testSubject.MakePurchase(new DateTime(2014, 2, 6), new Pecuniam(47.24M));
            testSubject.MakePurchase(new DateTime(2014, 2, 7), new Pecuniam(55.95M));
            testSubject.MakePurchase(new DateTime(2014, 2, 7), new Pecuniam(30.1M));
            testSubject.MakePurchase(new DateTime(2014, 2, 8), new Pecuniam(37.39M));
            testSubject.MakePurchase(new DateTime(2014, 2, 10), new Pecuniam(3.91M));
        }
Esempio n. 19
0
        public void TestIsValidDobOfChild()
        {
            var testPerson = American.RandomAmerican(new DateTime(1955, 6, 20), Gender.Female, false);

            testPerson.AddChild(American.RandomAmerican(new DateTime(1976, 10, 2), Gender.Female, false));
            testPerson.AddChild(American.RandomAmerican(new DateTime(1986, 3, 11), Gender.Female, false));
            testPerson.AddChild(American.RandomAmerican(new DateTime(1982, 12, 30), Gender.Female, 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 = American.RandomAmerican(new DateTime(1982, 4, 13), Gender.Female, false);
            testPerson.AddChild(American.RandomAmerican(new DateTime(2007, 8, 30), Gender.Male));
            testPerson.AddChild(American.RandomAmerican(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);
            Console.WriteLine(testDob);
        }
Esempio n. 20
0
        public void TestAddChild()
        {
            var testMother  = American.RandomAmerican(new DateTime(1970, 1, 1), Gender.Female);
            var testChild00 =
                American.RandomAmerican(testMother.BirthCert.DateOfBirth.AddYears(25).AddDays(28), Gender.Female);

            testMother.AddChild(testChild00);

            Assert.AreEqual(1, testMother.Children.Count());

            var testChild01 = American.RandomAmerican(testChild00.BirthCert.DateOfBirth.AddDays(28), Gender.Female);

            //cannot add this child since DoB violates biological constraints
            testMother.AddChild(testChild01);
            Assert.AreEqual(1, testMother.Children.Count());

            //but this is ok
            testMother.AddChild(testChild01, KindsOfNames.Mother | KindsOfNames.Adopted);
            Assert.AreEqual(2, testMother.Children.Count());

            //adding child does not add parent
            Assert.IsNull(testChild01.GetParent(KindsOfNames.Mother | KindsOfNames.Adopted));
        }