public static IEnumerable <Student> GetStudents() { if (StudentList.Count() == 0) { var id = 1; var testStudents = new Faker <Student>() .RuleFor(s => s.Id, f => id++) .RuleFor(s => s.FirstName, (f) => f.Person.FirstName) .RuleFor(s => s.LastName, (f) => f.Person.LastName) .RuleFor(s => s.Age, (f) => f.Random.Number(18, 50)) .RuleFor(s => s.Balance, (f) => f.Random.Decimal(1000M, 2000000M)) .RuleFor(s => s.DateOfBirth, (f) => f.Person.DateOfBirth).Generate(20); testStudents.Add(new Student { FirstName = null, LastName = "Adewale", DateOfBirth = DateTime.Now, Age = 30, Balance = 2000M }); testStudents.Add(new Student { FirstName = "", LastName = "Yaya", DateOfBirth = DateTime.Now, Age = 25, Balance = 3000M }); testStudents.Add(new Student { FirstName = "Johnson", LastName = "", DateOfBirth = DateTime.Now, Age = 25, Balance = null }); testStudents.Add(new Student { FirstName = "Frank", LastName = "Lampard", DateOfBirth = DateTime.Now, Age = null, Balance = 20000M }); StudentList = testStudents; } return(StudentList); }
public static List <Country> Countries(int count) { var countries = new Faker <Country>() .RuleFor(o => o.CountryId, f => f.IndexFaker + 1) .RuleFor(o => o.CountryName, f => f.Address.Country()) .RuleFor(o => o.CountryCode, f => f.Address.CountryCode()) .Generate(count); if (countries.Exists(c => c.CountryName == "Australia")) { countries.Single(c => c.CountryName == "Australia").CountryCode = "AU"; } else { countries.Add(new Country { CountryId = count + 1, CountryCode = "AU", CountryName = "Australia" }); } return(countries); }