예제 #1
0
        public List <Provider> GenerateProvider(int quantity,
                                                bool withContact     = true,
                                                bool useValidContact = true,
                                                bool withAddress     = true,
                                                bool useValidAddress = true)
        {
            var addressFixture = new AddressTestFixture();
            var contactFixtute = new ContactTestFixture();
            var provider       = new Faker <Provider>()
                                 .CustomInstantiator(f => new Provider(Guid.NewGuid(), f.Person.FullName, f.Company.Cnpj()))
                                 .FinishWith((f, p) =>
            {
                if (withAddress)
                {
                    if (useValidAddress)
                    {
                        p.AddAddresses(addressFixture.GenerateAddress(2));
                    }
                    else
                    {
                        p.AddAddress(addressFixture.GenerateInvalidAddress());
                        p.AddAddress(addressFixture.GenerateInvalidAddress());
                        p.AddAddress(addressFixture.GenerateInvalidAddress());
                    }
                }

                if (withContact)
                {
                    if (useValidContact)
                    {
                        p.AddContacts(contactFixtute.GenerateContact(Enums.EnumTypeContact.TypeContactCellPhone, 2));
                        p.AddContact(contactFixtute.GenerateValidContactTypeEmail());
                    }
                    else
                    {
                        p.AddContact(contactFixtute.GenerateInvalidContactTypeCellPhone());
                        p.AddContact(contactFixtute.GenerateInvalidContactTypeEmail());
                        p.AddContact(contactFixtute.GenerateInvalidContactTypePhone());
                    }
                }
            });

            return(provider.Generate(quantity));
        }
예제 #2
0
        public List <Client> GenerateClient(int quantity,
                                            bool withAddress     = true,
                                            bool hasValidAddress = true,
                                            bool withContact     = true,
                                            bool hasValidContact = true)
        {
            var addressFixture  = new AddressTestFixture();
            var contactsFixture = new ContactTestFixture();

            var client = new Faker <Client>("pt_BR")
                         .CustomInstantiator(f => new Client(Guid.NewGuid(),
                                                             f.Name.FullName(),
                                                             f.Person.Cpf()))
                         .FinishWith((f, c) =>
            {
                if (withAddress)
                {
                    if (hasValidAddress)
                    {
                        c.AddAddresses(addressFixture.GenerateAddress(2));
                    }
                    else
                    {
                        c.AddAddress(addressFixture.GenerateInvalidAddress());
                    }
                }
                if (withContact)
                {
                    if (hasValidContact)
                    {
                        c.AddContacts(contactsFixture.GenerateContact(EnumTypeContact.TypeContactCellPhone, 2));
                        c.AddContacts(contactsFixture.GenerateContact(EnumTypeContact.TypeContactEmail, 1));
                    }
                    else
                    {
                        c.AddContact(contactsFixture.GenerateInvalidContactTypeCellPhone());
                        c.AddContact(contactsFixture.GenerateInvalidContactTypeEmail());
                        c.AddContact(contactsFixture.GenerateInvalidContactTypePhone());
                    }
                }
            });

            return(client.Generate(quantity));
        }