public void FillDatabase() { var faker = new Faker("it"); var applications = Enumerable.Range(1, 10000).Select((i) => { var person = new Bogus.Person("it"); var app = new Application( person.CodiceFiscale(), person.FirstName, person.LastName, person.DateOfBirth.Date, person.Email, faker.Random.Replace("******"), new string[0], faker.Random.Number(10, 100), new License( faker.PickRandom("VVF", "Civile"), faker.PickRandom("A", "B", "C", "I cat.", "II cat.", "III cat.", "IV cat."), faker.Random.Replace("#####"), faker.PickRandom("Prefettura", "CNVVF"), faker.Date.Past(5, DateTime.Today.AddYears(-5)), faker.Date.Future(5) ) ); app.SourceIp = faker.Internet.Ip(); app.Anomalies = new Anomaly[0]; app.SubmissionTime = faker.Date.Between(DateTime.Now.AddMonths(-1), DateTime.Now); return(app); }); var dbContext = new DbContext("mongodb://localhost:27017/pca"); dbContext.Applications.InsertMany(applications); }
public void FillDatabase() { var faker = new Faker("it"); var applications = Enumerable.Range(1, 10000).Select((i) => { var person = new Bogus.Person("it"); var app = new Application( person.CodiceFiscale(), person.FirstName, person.LastName, person.DateOfBirth.Date, person.Email, faker.Random.Replace("******"), new string[0], faker.Random.Number(10, 100), faker.Lorem.Paragraph() ); app.SourceIp = faker.Internet.Ip(); app.Anomalies = new Anomaly[0]; app.SubmissionTime = faker.Date.Between(DateTime.Now.AddMonths(-1), DateTime.Now); return(app); }); var dbContext = new DbContext("mongodb://localhost:27017/pca"); dbContext.Applications.InsertMany(applications); }
public void OnExecute() { Logger.LogSuccess("Press CTRL+C to stop"); Thread.Sleep(1000); var people = new Faker <Bogus.Person>().GenerateForever(); int counter = 25000; while (true) { var stopwatch = new Stopwatch(); stopwatch.Start(); var person = new Bogus.Person(); counter++; Logger.Log($"Personnel record processing number: {counter}"); Logger.Log($" {person.FullName}"); Logger.Log($" {person.Email} {person.Gender}"); Logger.Log($" {person.DateOfBirth}"); Logger.Log($" {person.Address.Street}"); Logger.Log($" {person.Address.City} {person.Address.State} {person.Address.ZipCode}"); Logger.Log($" {person.Phone}"); stopwatch.Stop(); Logger.LogSuccess($" Completed record processing in {stopwatch.ElapsedTicks} ticks."); Thread.Sleep(200); } }
public void Validate_GamePlayList_ReturnsTrue() { var fakePerson = new Bogus.Person() { Random = new Randomizer(1080) }; var randomPhrase = new Bogus.DataSets.Hacker() { Random = new Randomizer(1080) }; var randomFluent = new Bogus.Faker() { Random = new Randomizer(1080) }; GameTrackPlaylist gameTrackPlaylist = new GameTrackPlaylist(); for (int count = 0; count < 10; count++) { Song fakeSong = new Song() { Title = randomPhrase.Phrase(), Album = randomPhrase.Phrase(), Composer = fakePerson.FullName }; Game fakeGame = new Game() { Title = randomPhrase.Phrase() }; DifficultyMode fakeMode = new DifficultyMode(); gameTrackPlaylist.Add(new Ez2OnGameTrack(fakeSong, fakeGame, fakeMode)); } gameTrackPlaylist.Name = randomPhrase.Phrase(); gameTrackPlaylist.DateTimeCreated = randomFluent.Date.Past(10, DateTime.Now); gameTrackPlaylist.DateTimeModified = randomFluent.Date.Future(10, DateTime.Now); GamePlayListValidator validator = new GamePlayListValidator(); ValidationResult results = validator.Validate(gameTrackPlaylist); Assert.True(results.IsValid); }
public void Assign_DefaultDateTimeModified_To_GamePlayList_ReturnsFalse() { var fakePerson = new Bogus.Person() { Random = new Randomizer(1080) }; var randomPhrase = new Bogus.DataSets.Hacker() { Random = new Randomizer(1080) }; var randomFluent = new Bogus.Faker() { Random = new Randomizer(1080) }; GameTrackPlaylist gameTrackPlaylist = new GameTrackPlaylist(); for (int count = 0; count < 10; count++) { Song fakeSong = new Song() { Title = randomPhrase.Phrase(), Album = randomPhrase.Phrase(), Composer = fakePerson.FullName }; Game fakeGame = new Game() { Title = randomPhrase.Phrase() }; DifficultyMode fakeMode = new DifficultyMode(); gameTrackPlaylist.Add(new Ez2OnGameTrack(fakeSong, fakeGame, fakeMode)); } gameTrackPlaylist.Name = randomPhrase.Phrase(); gameTrackPlaylist.DateTimeCreated = DateTime.Now; GamePlayListValidator validator = new GamePlayListValidator(); ValidationResult results = validator.Validate(gameTrackPlaylist); Assert.Contains(results.Errors, x => x.ErrorMessage == GamePlayListValidator.DateTimeModifiedErrorMessage); }
private static string Personnummer(this Bogus.Person p) { var r = p.Random; string formattedDateOfBirth = $"{p.DateOfBirth:yyMMdd}"; int rollingId = r.Int(100, 999); String[] digits = (formattedDateOfBirth + rollingId).Split(""); var checksum = 0; for (int i = 0; i < digits.Length; i++) { var n = int.Parse(digits[i]) * (2 - i % 2); checksum += n / 10 + n % 10; } checksum = checksum % 10 == 10 ? 0 : checksum % 10; return($"{p.DateOfBirth:ddMMyy}{rollingId}{checksum}"); }
public static string PersonIdNumber(this Bogus.Person p, string countryCode) { switch (countryCode) { case "fi": return(p.Henkilötunnus()); case "nb_NO": return(p.Fødselsnummer()); case "sv": return(p.Personnummer()); case "dk": return(p.Cpr()); default: return(null); } }
protected override void Seed(EmployeeContext context) { var employees = new List <Employee> { }; for (int i = 0; i < 15; i++) { var fake = new Bogus.Person(); var fake_employee = new Employee { First_Name = fake.FirstName, Last_Name = fake.LastName, Phone_Cell = fake.Phone, Active = false }; employees.Add(fake_employee); } employees.ForEach(e => context.Employees.Add(e)); context.SaveChanges(); }
public static string Initials(this Bogus.Person p) { return(p.FirstName.Substring(0, 1)); }