コード例 #1
0
ファイル: FakeUsers.cs プロジェクト: jgauffin/Griffin.Table
        public List <UserEntity> Generate(int count)
        {
            var fn = new FirstNames();
            var ln = new LastNames();
            var d  = new Departments();
            var t  = new Titles();
            var r  = new Random();

            List <UserEntity> users = new List <UserEntity>();

            for (int i = 0; i < count; i++)
            {
                var user = new UserEntity
                {
                    Id         = i + 1,
                    Age        = r.Next(1, 100),
                    Department = d.GetRandom(),
                    FirstName  = fn.GetRandom(),
                    LastName   = ln.GetRandom(),
                    Title      = t.GetRandom()
                };
                users.Add(user);
            }

            return(users);
        }
コード例 #2
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();
        }
コード例 #3
0
 public static Host GenerateHost() => new Host
 {
     Name     = $"{FirstNames.GetRandom()} {LastNames.GetRandom()}",
     Job      = $"{Jobs1.GetRandom()} {Jobs2.GetRandom()}",
     ImageUrl = ImageUrls.GetRandom(),
 };