Пример #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));
        }
Пример #3
0
        public List <ProviderViewModel> GenerateValidProviderViewModel(int qty,
                                                                       List <CityViewModel> citiesViewModel,
                                                                       int qtyAddress      = 0,
                                                                       int qtyContacts     = 0,
                                                                       bool isValidAddress = true,
                                                                       bool isValidContact = true)
        {
            var addressFixture  = new AddressTestFixture();
            var contactsFixture = new ContactTestFixture();

            var client = new Faker <ProviderViewModel>("pt_BR")
                         .FinishWith(
                (f, p) =>
            {
                p.Name      = f.Company.CompanyName();
                p.Document  = f.Company.Cnpj();
                p.Addresses = addressFixture.GenerateAddress(qtyAddress, isValidAddress, addressFixture, citiesViewModel);
                p.Contacts  = contactsFixture.GenerateContact(qtyContacts, isValidContact, contactsFixture);
            });

            return(client.Generate(qty));
        }
Пример #4
0
        public List <ClientViewModel> GenerateClientViewModel(int qtyClients,
                                                              List <CityViewModel> citiesViewModel,
                                                              int qtyAddress      = 0,
                                                              int qtyContacts     = 0,
                                                              bool isValidAddress = true,
                                                              bool isValidContact = true)
        {
            var addressFixture  = new AddressTestFixture();
            var contactsFixture = new ContactTestFixture();

            var client = new Faker <ClientViewModel>("pt_BR")
                         .FinishWith(
                (f, c) =>
            {
                c.Name      = f.Name.FullName();
                c.Document  = f.Person.Cpf();
                c.Addresses = addressFixture.GenerateAddress(qtyAddress, isValidAddress, addressFixture, citiesViewModel);
                c.Contacts  = contactsFixture.GenerateContact(qtyContacts, isValidContact, contactsFixture);
            });

            return(client.Generate(qtyClients));
        }