Пример #1
0
        public void TestDeathDate()
        {
            var dob        = Etx.RandomAdultBirthDate();
            var testResult = AmericanDeathCert.RandomDeathDate(dob, Gender.Female.ToString());

            Assert.AreNotEqual(dob, testResult);
            Console.WriteLine("{0} - {1}", dob, testResult);
        }
Пример #2
0
        /// <summary>
        /// Generates a <see cref="DeathCert"/> at random based on the given <see cref="p"/>
        /// </summary>
        /// <param name="p"></param>
        /// <param name="nullOnFutureDate">
        /// Switch parameter to have null returned whenever the random date-of-death is
        /// in the future.
        /// </param>
        /// <returns></returns>
        public static DeathCert GetRandomDeathCert(IPerson p, bool nullOnFutureDate = true)
        {
            if (p?.BirthCert == null)
            {
                return(null);
            }

            var deathDate = AmericanDeathCert.RandomDeathDate(p.BirthCert.DateOfBirth, p.Gender.ToString());

            if (nullOnFutureDate && deathDate > DateTime.UtcNow)
            {
                return(null);
            }

            var manner = Etx.RandomPickOne(AmericanData.MannerOfDeathAvgs);

            return(new AmericanDeathCert(manner, String.Join(" ", p.FirstName, p.LastName))
            {
                DateOfDeath = deathDate
            });
        }