private async Task <EmployeeEntity[]> FakeEmployees(IEnumerable <SalesmanEntity> salesmen, int count) { var salesmenSns = salesmen.Select(x => x.Sn).ToList(); var faker = new Faker <EmployeeEntity>() .RuleFor(x => x.ID, f => f.Person.Ssn()) .RuleFor(x => x.Email, f => f.Person.Email) .RuleFor(x => x.Gender, f => f.PickRandom <EmployeeEntity.GenderTypes>()) .RuleFor(x => x.PicPath, (f, x) => f.Image.LoremFlickrUrl(keywords: f.PickRandom("man", "woman", "face", "person"))) .RuleFor(x => x.FirstName, f => f.Person.FirstName) .RuleFor(x => x.LastName, f => f.Person.LastName) .RuleFor(x => x.IsActive, f => true) .RuleFor(x => x.SalesmanSN, f => { if (salesmenSns.Count == 0) { return(null); } var sn = salesmenSns[0]; salesmenSns.RemoveAt(0); return(sn); }) .RuleFor(x => x.HomeAddress, f => AddressFaker.Generate()) .RuleFor(x => x.WorkAddress, f => AddressFaker.Generate()) .RuleFor(x => x.HomePhone, f => f.Person.Phone) .RuleFor(x => x.JobTitle, f => f.Lorem.Word()) ; _dbContext.Employees.AddRange(faker.Generate(count)); await _dbContext.SaveChangesAsync(); return(await _dbContext.Employees.ToArrayAsync()); }
public void SetUp() { _fakerContainer = A.Fake <IFakerContainer>(); _addressFaker = new AddressFaker(_fakerContainer); A.CallTo(() => _fakerContainer.Fake).Returns(new FakeFaker(_fakerContainer)); }
public FakerContainer() { Address = new AddressFaker(this); App = new AppFaker(this); Beer = new BeerFaker(this); Book = new BookFaker(this); Boolean = new BooleanFaker(); Business = new BusinessFaker(this); Color = new ColorFaker(this); Company = new CompanyFaker(this); Date = new DateFaker(); Fake = new FakeFaker(this); Friends = new FriendsFaker(this); GameOfThrones = new GameOfThronesFaker(this); Lorem = new LoremFaker(this); Name = new NameFaker(this); Number = new NumberFaker(); Pokemon = new PokemonFaker(this); Random = new RandomFaker(); RockBand = new RockBandFaker(this); Superhero = new SuperheroFaker(this); Team = new TeamFaker(this); Time = new TimeFaker(); TwinPeaks = new TwinPeaksFaker(this); Zelda = new ZeldaFaker(this); }
public IHttpActionResult Post(Order order) { AddressFaker addressFaker = new AddressFaker(); CustomerFaker customerFaker = new CustomerFaker(addressFaker); order = new Order { Customer = new Customer { Id = 4 }, Details = new List <OrderDetail> { new OrderDetail { Item = new Product { Id = 1 }, Quantity = 3, UnitPrice = 2 }, new OrderDetail { Item = new Product { Id = 2 }, Quantity = 5, UnitPrice = 10 }, }, ShipAddress = addressFaker.Generate() }; orderService.Add(order); return(CreatedAtRoute("DefaultApi", new { Id = order.Id }, order)); }
public void DeveRetornarEnderecoCidadeInvalida() { address = AddressFaker.Gerar(); var vO = address.Generate(); add = new Address(vO.Street, vO.Number, vO.Neighborhood, "", vO.StateName, vO.Country, vO.ZipCode, vO.Abbr); Assert.True(add.Invalid); }
public void DeveRetornarEnderecoBairroInvalido() { address = AddressFaker.Gerar(); var vO = address.Generate(); add = new Address(vO.Street, vO.Number, "", vO.City, vO.StateName, vO.Country, vO.ZipCode, vO.Abbr); Assert.True(add.Invalid); }
public void DeveRetornarEstadoNomeInvalido() { address = AddressFaker.Gerar(); var vO = address.Generate(); add = new Address(vO.Street, vO.Number, vO.Neighborhood, vO.City, "", vO.Country, vO.ZipCode, vO.Abbr); Assert.True(add.Invalid); }
public void DeveRetornarEnderecoCepFormatoInvalido() { address = AddressFaker.Gerar(); var vO = address.Generate(); add = new Address(vO.Street, vO.Number, vO.Neighborhood, vO.City, vO.StateName, vO.Country, "66.777000", vO.Abbr); Assert.True(add.Invalid); }
public static Faker <Domain.Entities.School> Gerar() { Faker <Domain.Entities.School> school = new Faker <Domain.Entities.School>("pt_BR") .RuleFor(s => s.Name, f => f.Company.CompanyName()) .RuleFor(s => s.Document, f => JuridiqueDocument()) .RuleFor(s => s.Address, AddressFaker.Gerar()) .RuleFor(s => s.Phone, f => f.Phone.PhoneNumberFormat()); return(school); }
public FakerContainer() { Address = new AddressFaker(this); App = new AppFaker(this); Book = new BookFaker(this); Boolean = new BooleanFaker(); Date = new DateFaker(); Fake = new FakeFaker(this); Name = new NameFaker(this); Number = new NumberFaker(); Random = new RandomFaker(); Time = new TimeFaker(); Zelda = new ZeldaFaker(this); }
public FakerContainer() { Address = new AddressFaker(this); Ancient = new AncientFaker(this); App = new AppFaker(this); Avatar = new AvatarFaker(this); Beer = new BeerFaker(this); Book = new BookFaker(this); Boolean = new BooleanFaker(); Business = new BusinessFaker(this); Cat = new CatFaker(this); ChuckNorris = new ChuckNorrisFaker(this); Coffee = new CoffeeFaker(this); Color = new ColorFaker(this); Company = new CompanyFaker(this); Date = new DateFaker(); DragonBall = new DragonBallFaker(this); Educator = new EducatorFaker(this); Fake = new FakeFaker(this); File = new FileFaker(this); Fillmurray = new FillmurrayFaker(); Food = new FoodFaker(this); Friends = new FriendsFaker(this); GameOfThrones = new GameOfThronesFaker(this); Hacker = new HackerFaker(this); HarryPotter = new HarryPotterFaker(this); Internet = new InternetFaker(this); LordOfTheRings = new LordOfTheRingsFaker(this); Lorem = new LoremFaker(this); Music = new MusicFaker(this); Name = new NameFaker(this); Number = new NumberFaker(); PhoneNumber = new PhoneNumberFaker(this); Placeholdit = new PlaceholditFaker(this); Pokemon = new PokemonFaker(this); Random = new RandomFaker(); RickAndMorty = new RickAndMortyFaker(this); RockBand = new RockBandFaker(this); SlackEmoji = new SlackEmojiFaker(this); Space = new SpaceFaker(this); StarWars = new StarWarsFaker(this); Superhero = new SuperheroFaker(this); Team = new TeamFaker(this); Time = new TimeFaker(); TwinPeaks = new TwinPeaksFaker(this); University = new UniversityFaker(this); Vehicle = new VehicleFaker(this); Zelda = new ZeldaFaker(this); }
private async Task <BusinessPartner[]> FakeBusinessPartners(IEnumerable <SalesmanEntity> salesmen, IEnumerable <CardGroup> cardGroups, int count) { var faker = new Faker <BusinessPartner>() .RuleFor(c => c.PartnerType, f => f.PickRandom <BusinessPartner.PartnerTypes>()) .RuleFor(c => c.Type, f => f.PickRandom <BusinessPartner.CardType>()) .RuleFor(c => c.CreationDateTime, f => f.Date.Past(6, DateTime.Now)) .RuleFor(c => c.LastUpdateDateTime, (f, c) => new Random().Next(10) < 4 ? f.Date.Between(c.CreationDateTime.Value, DateTime.Now) : new DateTime?()) .RuleFor(c => c.Name, (f, c) => f.Company.CompanyName()) .RuleFor(c => c.FederalTaxId, (f, c) => f.Company.Ein()) .RuleFor(i => i.Currency, f => "$") .RuleFor(c => c.Email, (f, c) => new Random().Next(10) < 6 ? f.Internet.Email(c.Name) : null) .RuleFor(c => c.Phone1, (f, c) => f.Phone.PhoneNumber("0#-#######")) .RuleFor(c => c.Phone2, (f, c) => new Random().Next(10) < 4 ? f.Phone.PhoneNumber("05#-#######") : null) .RuleFor(c => c.Cellular, (f, c) => f.Phone.PhoneNumber("05#-#######")) .RuleFor(c => c.Fax, (f, c) => new Random().Next(10) < 4 ? f.Phone.PhoneNumber("0#-#######") : null) .RuleFor(c => c.IsActive, f => true /*f.Random.Bool()*/) .RuleFor(c => c.GroupSn, (f, c) => f.PickRandom(cardGroups).Sn) .RuleFor(c => c.SalesmanCode, (f, c) => f.PickRandom(salesmen).Sn) .RuleFor(c => c.ShippingAddress, (f, c) => AddressFaker.Generate()) .RuleFor(c => c.BillingAddress, (f, c) => AddressFaker.Generate()) .RuleFor(c => c.OrdersBalance, 0) .RuleFor(c => c.DeliveryNotesBalance, 0) .RuleFor(c => c.IsVatFree, f => f.Random.Bool()) .RuleFor(c => c.DiscountPercent, f => f.Random.Decimal()) .RuleFor(c => c.GeoLocation, (f, c) => new GeoLocation { Address = $"{c.BillingAddress.City},{c.BillingAddress.Street} {c.BillingAddress.NumAtStreet}", Latitude = 15.00, Longitude = 15.5656 }) .RuleFor(c => c.Balance, f => f.Random.Decimal()) .RuleFor(c => c.OrdersBalance, f => f.Random.Decimal()) .RuleFor(c => c.DeliveryNotesBalance, f => f.Random.Decimal()) ; _dbContext.BusinessPartners.AddRange(faker.Generate(count)); await _dbContext.SaveChangesAsync(); return(await _dbContext.BusinessPartners.ToArrayAsync()); }
public FakerContainer() { Address = new AddressFaker(this); App = new AppFaker(this); Book = new BookFaker(this); Boolean = new BooleanFaker(); Business = new BusinessFaker(this); Date = new DateFaker(); Fake = new FakeFaker(this); Friends = new FriendsFaker(this); Lorem = new LoremFaker(this); Name = new NameFaker(this); Number = new NumberFaker(); Pokemon = new PokemonFaker(this); Random = new RandomFaker(); Time = new TimeFaker(); Zelda = new ZeldaFaker(this); }
public void DeveRetornarEnderecoBairroTamanhoInvalido() { address = AddressFaker.Gerar(); var vO = address.Generate(); int i = 0; string length = ""; while (i < 50) { length += "teste"; i++; } add = new Address(vO.Street, vO.Number, vO.Neighborhood + length, vO.City, vO.StateName, vO.Country, vO.ZipCode, vO.Abbr); Assert.True(add.Invalid); }
public static Faker <Student> Gerar() { Faker <Student> student = new Faker <Student>("pt_BR") .RuleFor(s => s.Name, NameFaker.Gerar()) .RuleFor(s => s.Parents, ParentFaker.Gerar().Generate(2)) .RuleFor(s => s.Address, AddressFaker.Gerar()) .RuleFor(s => s.BirthDate, f => f.Date.Soon()) .RuleFor(s => s.ETypeOfEducation, f => f.PickRandom <ETypeOfEducation>()) .RuleFor(s => s.AcademicYear, f => f.Date.Soon()) .RuleFor(s => s.Serie, f => f.Random.Int(1)) .RuleFor(s => s.Grade, f => f.Random.String(1)) .RuleFor(s => s.Serie, f => f.Random.Int(1)) .RuleFor(s => s.Shifts, f => f.PickRandom <EShifts>()) .RuleFor(s => s.CalledNumber, f => f.Random.Int(1, 30)) .RuleFor(s => s.Note, f => f.Lorem.Paragraphs(1)) .RuleFor(s => s.School, SchoolFaker.Gerar()) .RuleFor(s => s.Occurrences, OccurrenceFaker.Gerar().Generate(1)); return(student); }