示例#1
0
        static MockPersonRepository()
        {
            var rng = new Random();

            // Ugly randomization to create different people
            people = Enumerable.Range(1, 30).Select(index => new Person
            {
                Id          = index,
                DateOfBirth = DateTime.Now.AddYears(-rng.Next(5, 40)),
                DateOfDeath = rng.Next(10) == 1 ? DateTime.Now.AddYears(-rng.Next(5)) : (DateTime?)null,
                FirstName   = FirstNames.GetRandom(),
                LastName    = LastNames.GetRandom(),
                Street1     = $"{rng.Next(999)} {Streets.GetRandom()} {StreetTypes.GetRandom()}",
                Street2     = rng.Next(10) < 3 ? $"Apt {rng.Next(1, 30)}" : null,
                City        = Cities.GetRandom(),
                State       = States.GetRandom(),
                PostalCode  = $"{rng.Next(99999):00000}",
                Interests   = rng.Next(10) < 5 ? Interests.GetRandom() : null,
                AvatarUrl   = $"/images/{(index % 2 == 0 ? "m" : "f")}/{index}.png"
            }).ToArray();
        }