Esempio n. 1
0
        public dynamic GenerateClientExpected()
        {
            var faker          = new Faker("pt_BR");
            var addressFixture = new AddressTestFixture();
            var contactFixture = new ContactTestFixture();

            return(new
            {
                Id = Guid.NewGuid(),
                Name = faker.Name.FullName(),
                Document = faker.Person.Cpf(),
                Address = addressFixture.GenerateAddressExpected(),
                ContactEmail = contactFixture.GenerateValidContactExpectedTypeEmail(),
                ContactPhone = contactFixture.GenerateValidContactExpectedTypePhone(),
                ContactCellPhone = contactFixture.GenerateValidContactExpectedTypeCellPhone()
            });
        }
Esempio n. 2
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));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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));
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
        public List <ContactViewModel> GenerateContact(int qtyContacts,
                                                       bool isValidContact,
                                                       ContactTestFixture contactsFixture)
        {
            if (qtyContacts > 0)
            {
                if (isValidContact)
                {
                    List <ContactViewModel> contacts = contactsFixture.GenerateValidContactViewModel(EnumTypeContact.TypeContactCellPhone, qtyContacts);
                    contacts.AddRange(contactsFixture.GenerateValidContactViewModel(EnumTypeContact.TypeContactEmail, qtyContacts));
                    return(contacts);
                }
                else
                {
                    List <ContactViewModel> contacts = new List <ContactViewModel>();

                    contacts.AddRange(contactsFixture.GenerateInvalidContactViewModel(EnumTypeContact.TypeContactCellPhone, qtyContacts));
                    contacts.AddRange(contactsFixture.GenerateInvalidContactViewModel(EnumTypeContact.TypeContactPhone, qtyContacts));
                    contacts.AddRange(contactsFixture.GenerateInvalidContactViewModel(EnumTypeContact.TypeContactEmail, qtyContacts));
                    return(contacts);
                }
            }
            return(null);
        }