Esempio n. 1
0
        public void CN001_Alunos_ValidarCadastroAlunos()
        {
            var faker     = new Faker("en");
            var nameMock  = new Bogus.DataSets.Name();
            var firstName = nameMock.FirstName(Bogus.DataSets.Name.Gender.Male);
            var lastName  = nameMock.LastName(Bogus.DataSets.Name.Gender.Male);

            aluno = new AlunoMock()
            {
                CPF            = faker.Random.Long(11111111111, 99999999999).ToString(),
                RG             = faker.Random.Long(1111111, 9999999).ToString(),
                Telefone       = faker.Phone.PhoneNumber(),
                DataNascimento = "01/01/1991",
                UserName       = faker.Internet.UserName(firstName, lastName),
                Email          = faker.Internet.Email(firstName, lastName, "portabilis.com"),
                Senha          = faker.Internet.Password(8, true),
                Name           = firstName + " " + lastName
            };

            this.CN001_Alunos_AcessarCadastro();
            this.CN001_Alunos_CadastrarAluno();

            this.CN001_Alunos_AcessarCadastro();
            this.CN001_Alunos_CadastrarAluno();

            this.CN001_Alunos_ValidarAlunoCPFDuplicado();

            this.CN001_Alunos_FazerLoginAluno();
            this.CN001_Alunos_BuscarIdAluno();

            driver.Close();
        }
Esempio n. 2
0
        public void Test_Indexed_Persons_Sorted_Paging_By_Index()
        {
            const int ITEMS_COUNT = 100;

            const string INDEX_NAME_NAME = "name";

            // definizione indice su entità Person
            var persons = new Index <Person>(
                new IndexMaker <Person, string>(INDEX_NAME_NAME, p => p.FirstName)
                );

            // Generiamo ITEMS_COUNT entità casuali
            var fakerRandomizer  = new Bogus.Randomizer();
            var fakerNameDataset = new Bogus.DataSets.Name("en");

            for (var i = 0; i < ITEMS_COUNT; i++)
            {
                persons.Add(new Person(
                                fakerNameDataset.FirstName(),
                                fakerNameDataset.LastName(),
                                fakerRandomizer.Int(1900, 2000) * 10000 + fakerRandomizer.Int(1, 12) * 100 + fakerRandomizer.Int(1, 31)));
            }

            // Enumeriamo gli ultimi 10 item ordinati desc per l'indice creato
            const int PAGE_SIZE = ITEMS_COUNT / 10;

            _output.WriteLine($"Ultimi {PAGE_SIZE} item in ordine inverso:\n");

            var lastPageByName = persons[INDEX_NAME_NAME].AsEnumerable().Skip(ITEMS_COUNT - PAGE_SIZE).Take(PAGE_SIZE).Reverse();

            foreach (var p in lastPageByName)
            {
                _output.WriteLine($"{p.FirstName}");
            }
        }
Esempio n. 3
0
        public CustomFaker(string locale, double mistakesNumber)
        {
            switch (locale)
            {
            case "en_US":
                this.locale = "en_US";
                break;

            case "ru_RU":
                this.locale = "ru";
                break;

            case "be_BY":
                this.locale = "be";
                break;

            default:
                throw new ArgumentException($"Unsupported locale: {locale}");
            }

            this.mistakesNumber = mistakesNumber;
            nameDataSet         = new Bogus.DataSets.Name(this.locale);
            addressDataSet      = new Bogus.DataSets.Address(this.locale);
            phoneNumbersDataSet = new Bogus.DataSets.PhoneNumbers(this.locale);
            loremDataSet        = new Bogus.DataSets.Lorem(this.locale);
            random = new Random();
        }
Esempio n. 4
0
        public Game gameGenerate()
        {
            var numPlayers   = new Bogus.DataSets.Commerce().Random.Int(1, 3);
            var numMovements = new Bogus.DataSets.Commerce().Random.Int(1, 5);
            var name         = new Bogus.DataSets.Name();
            var word         = new Bogus.DataSets.Hacker();
            var players      = new List <Player>();

            for (var i = 0; i < numPlayers; i++)
            {
                var longitude = new Bogus.DataSets.Address().Longitude();
                var latitude  = new Bogus.DataSets.Address().Latitude();
                var movements = new List <Movement>();
                for (var j = 0; j < numMovements; j++)
                {
                    movements.Add(new Movement()
                    {
                        playedAt = DateTime.UtcNow, word = word.Noun()
                    });
                }
                players.Add(new Player()
                {
                    username = name.FirstName(), joinedAt = DateTime.UtcNow, movements = movements, longitude = longitude, latitude = latitude
                });
            }
            return(new Game()
            {
                owner = name.FirstName(), maxPlayers = 3, type = "TEST", createdAt = DateTime.UtcNow, players = players, state = GameStates.Open
            });
        }
        public void EnterDistributionName()
        {
            var name = new Bogus.DataSets.Name().Random.Word();

            this.WaitForElementToBeVisible(By.XPath("//input[@name='distributionName']")).SendKeys(name);
            Thread.Sleep(2000);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            // create data sets
            var nameDataSet    = new Bogus.DataSets.Name();
            var addressDataSet = new Bogus.DataSets.Address();
            var phoneDataSet   = new Bogus.DataSets.PhoneNumbers();

            // create list to hold results
            var list = new List <Address>();

            for (var i = 0; i < 780000; i++)
            {
                // generate a result
                var address = new Address();

                address.First = nameDataSet.FirstName();
                address.Last  = nameDataSet.LastName();

                address.Street = addressDataSet.StreetAddress();
                address.City   = addressDataSet.City();
                address.State  = addressDataSet.State();
                address.Zip    = addressDataSet.ZipCode();
                address.Phone  = phoneDataSet.PhoneNumberFormat(0);

                list.Add(address);
            }

            // serialize to output.json
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(list);

            File.WriteAllText("output.json", json);
        }
Esempio n. 7
0
        public static string FullName()
        {
            var firstName = new Bogus.DataSets.Name().FirstName().ToString();
            var lastName  = new Bogus.DataSets.Name().LastName().ToString();

            return($"{firstName}  {lastName}");
        }
        public void Trello_1_SignUp_in_Trello()
        {
            //Cannot be done because of CAPTCHA
            SignUpPage signUp = new SignUpPage(webDriver);

            string fullName = new Bogus.DataSets.Name().FullName();

            signUp.SignUpInTrello();

            HomePage homePage = new HomePage(webDriver);

            homePage.GetPersonalBoardsText
            .Should().Contain("Personal Boards");
        }
Esempio n. 9
0
        private static Customer CreateCustomer(_CustomerType type)
        {
            var name    = new Bogus.DataSets.Name();
            var address = new Bogus.DataSets.Address();
            var random  = new Randomizer();

            if (type == _CustomerType.Individual)
            {
                var phoneNo = new Bogus.DataSets.PhoneNumbers();

                return(new IndividualCustomer()
                {
                    FirstName = name.FirstName(),
                    LastName = name.LastName(),
                    CustomerType = type.ToString(),
                    Street = address.StreetName(),
                    City = address.City(),
                    State = address.State(),
                    Zipcode = int.Parse(address.ZipCode("######")),
                    PhoneNo = int.Parse(phoneNo.PhoneNumber("########")),
                    Age = random.Number(18, 100),
                    Gender = (int)random.Enum <_Gender>()
                });
            }
            else if (type == _CustomerType.Enterprise)
            {
                var companyName = new Bogus.DataSets.Company();

                return(new EnterpriseCustomer()
                {
                    FirstName = name.FirstName(),
                    LastName = name.LastName(),
                    CustomerType = type.ToString(),
                    Street = address.StreetName(),
                    City = address.City(),
                    State = address.State(),
                    Zipcode = int.Parse(address.ZipCode("######")),
                    OrganizationName = companyName.CompanyName() + companyName.CompanySuffix(),
                    OrganizationType = random.Enum <_OrganizationType>().ToString()
                });
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
        public void SignUpInTrello()
        {
            SafeClick(signUpButtonOnwelcomePage);
            var    emailSignup = FindElement(enterEmailSignUpInput);
            string email       = new Bogus.DataSets.Internet("en_GB").Email();

            emailSignup.SendKeys(email);

            SafeClick(signUpContinueButton);

            var    fullNameSignUp = FindElement(enterFullNameSignUpInput);
            string fullName       = new Bogus.DataSets.Name("en_GB").FullName();

            fullNameSignUp.SendKeys(fullName);
            var    passwordSignUp = FindElement(createPasswordSignUpInput);
            string pwd            = new Bogus.DataSets.Internet("en_GB").Password();

            passwordSignUp.SendKeys(pwd);

            SafeClick(signUpButton);
        }
Esempio n. 11
0
        /// <summary>
        /// Создает новый экземпляр сгенерированных данных о людях
        /// </summary>
        /// <param name="personsCount">Необходимое количество сгенерированных людей</param>
        public FakePersonEntities(int personsCount, FakePersonTypeEntities personTypes)
        {
            var nameRu = new Bogus.DataSets.Name("ru");

            PersonFaker = new Faker <PersonEntity>()
                          .RuleFor(p => p.Id, f => f.IndexFaker)
                          .RuleFor(p => p.FullNameRu, f => nameRu.FullName())
                          .RuleFor(p => p.FullNameEn, f => f.Person.FullName)
                          .RuleFor(p => p.LostfilmPersonalPageUrl, f => f.Internet.Url())
                          .RuleFor(p => p.PhotoThumbnailUrl, f => f.Internet.Url())
                          .RuleFor(p => p.PersonType, f => f.PickRandom(personTypes.PersonTypeEntities))
                          .RuleFor(p => p.ListTvSerias, () => new List <TvSeriasEntity>());

            PersonEntities = PersonFaker.Generate(personsCount);

            foreach (var personEntity in PersonEntities)
            {
                personEntity.PersonTypeCode = personEntity.PersonType.Code;
                personEntity.PersonType.Persons.Add(personEntity);
            }
        }
Esempio n. 12
0
        public void AddNewCase()
        {
            var fName   = new Bogus.DataSets.Name().Random.Word();
            var lName   = new Bogus.DataSets.Name().Random.Word();
            var mName   = new Bogus.DataSets.Name().Random.Word();
            var title   = new Bogus.DataSets.Name().Prefix();
            var caseNum = new Faker().Random.Number(999999);

            date = DateTime.Now.Date.ToString("MM/dd/yy");
            WaitForElementToBeVisible(addCaseButton).Click();
            WaitForElementToBeVisible(caseNumberValue).SendKeys(caseNum.ToString());
            WaitForElementToBeVisible(petitionDate).SendKeys(date);
            Pause(2);
            WaitForElementToBeVisible(meetingDate).SendKeys(date);
            this.ScrollDown();
            this.WaitForElementToBeVisible(newParticipant).Click();
            SelectParticipantType("Individual");
            ScrollDown();
            InputNames(fName, mName, lName);
            ScrollDownToPageBottom();
            // this.WaitForElementToBeVisible(saveButton).Click();
        }
Esempio n. 13
0
        public void CN002_Cursos_ValidarCadastroCursos()
        {
            this.CN002_Cursos_AcessarCadastro();

            var faker     = new Faker("en");
            var nameMock  = new Bogus.DataSets.Name();
            var firstName = nameMock.FirstName(Bogus.DataSets.Name.Gender.Male);
            var lastName  = nameMock.LastName(Bogus.DataSets.Name.Gender.Male);

            curso = new CursoMock()
            {
                Name = "Curso Portabilis",
                //ValMatricula = Math.Round(faker.Random.Decimal(decimal.Parse("50"), decimal.Parse("100")), 2).ToString(),
                //ValMensalidade = Math.Round(faker.Random.Decimal(decimal.Parse("200"), decimal.Parse("800")),2).ToString(),
                ValMatricula      = faker.Random.Number(50, 100).ToString(),
                ValMensalidade    = faker.Random.Number(20, 800).ToString(),
                Periodo           = "noturno",
                Descricao         = faker.Lorem.Sentence(15),
                QuantMesesDuracao = "12"
            };

            this.CN002_Cursos_CadastrarCurso();
            this.CN002_Cursos_BuscarIdCurso();
        }
Esempio n. 14
0
        public void CN003_Matriculas_ValidarCadastroMatriculas()
        {
            driver = Application.StartApplication();

            var faker     = new Faker("en");
            var nameMock  = new Bogus.DataSets.Name();
            var firstName = nameMock.FirstName(Bogus.DataSets.Name.Gender.Male);
            var lastName  = nameMock.LastName(Bogus.DataSets.Name.Gender.Male);

            aluno = new AlunoMock()
            {
                CPF            = faker.Random.Long(11111111111, 99999999999).ToString(),
                RG             = faker.Random.Long(1111111, 9999999).ToString(),
                Telefone       = faker.Phone.PhoneNumber(),
                DataNascimento = "01/01/1991",
                UserName       = faker.Internet.UserName(firstName, lastName),
                Email          = faker.Internet.Email(firstName, lastName, "portabilis.com"),
                Senha          = faker.Internet.Password(8, true),
                Name           = firstName + " " + lastName
            };

            CN001_Alunos alunosCenary = new CN001_Alunos();

            CN001_Alunos.aluno  = aluno;
            CN001_Alunos.driver = driver;

            alunosCenary.CN001_Alunos_AcessarCadastro();
            alunosCenary.CN001_Alunos_CadastrarAluno();

            curso = new CursoMock()
            {
                Name              = "Curso " + faker.Lorem.Sentence(1),
                ValMatricula      = faker.Random.Number(50, 100).ToString(),
                ValMensalidade    = faker.Random.Number(20, 800).ToString(),
                Periodo           = "noturno",
                Descricao         = faker.Lorem.Sentence(15),
                QuantMesesDuracao = "12"
            };

            CN002_Cursos cursosCenary = new CN002_Cursos();

            CN002_Cursos.curso  = curso;
            CN002_Cursos.driver = driver;

            cursosCenary.CN002_Cursos_AcessarCadastro();
            cursosCenary.CN002_Cursos_CadastrarCurso();
            cursosCenary.CN002_Cursos_BuscarIdCurso();

            matricula = new MatriculaMock()
            {
                Ano   = "2018",
                Curso = curso.Name
            };

            this.CN003_Matriculas_AcessarCadastro();
            this.CN003_Matriculas_CadastrarMatricula();

            this.CN003_Matriculas_BuscarIdMatricula();

            matriculaAluno = new MatriculaAlunoMock()
            {
                Aluno   = aluno.Name,
                Curso   = curso.Name,
                Periodo = "noturno",
                Ano     = "2018"
            };

            this.CN003_Matriculas_AcessarCadastroAlunoDetail();
            this.CN003_Matriculas_CadastrarMatriculaAlunoDetail();

            Thread.Sleep(2000);

            this.CN003_Matriculas_AcessarCadastroAluno();
            this.CN003_Matriculas_CadastrarMatriculaAluno();

            this.CN003_Matriculas_ValidarMatriculaDuplicada();

            Application.DoLogout(driver);

            Application.DoLogin(driver, aluno.UserName, aluno.Senha);

            this.CN003_Matriculas_AcessarDetalheMatricula();

            this.CN003_Matriculas_PagarMatricula();

            driver.Navigate().GoToUrl("http://mighty-waters-85986.herokuapp.com/aluno/dashboard");

            this.CN003_Matriculas_AcessarDetalheMatricula();

            this.CN003_Matriculas_PagarMensalidade();

            this.CN003_Matriculas_ValidarPagamento();

            driver.Navigate().GoToUrl("http://mighty-waters-85986.herokuapp.com/aluno/dashboard");

            this.CN003_Matriculas_AcessarDetalheMatricula();

            //this.CN003_Matriculas_ExcluirMatricula();
        }
Esempio n. 15
0
        public void Test_Indexed_Persons_Find_By_Index()
        {
            const int ITEMS_COUNT = 1000000;

            const string INDEX_NAME_YEAR  = "year";
            const string INDEX_NAME_MONTH = "month";
            const string INDEX_NAME_DAY   = "day";
            const string INDEX_NAME_NAME  = "name";

            // Lookup
            string[] months =
            {
                "Jan",
                "Feb",
                "Mar",
                "Apr",
                "May",
                "Jun",
                "Jul",
                "Aug",
                "Sep",
                "Oct",
                "Nov",
                "Dec"
            };

            // definizione indici su entità Person
            var persons = new Index <Sample_Entities.Person>(
                new IndexMaker <Person, string>(INDEX_NAME_NAME, p => p.FirstName),
                new IndexMaker <Person, int>(INDEX_NAME_YEAR, p => p.Date / 10000),
                new IndexMaker <Person, int>(INDEX_NAME_DAY, p => p.Date % 100),
                new IndexMaker <Person, string>(INDEX_NAME_MONTH, p => months[p.Date / 100 % 100 - 1])
                );

            // Generiamo ITEMS_COUNT entità casuali
            var fakerRandomizer  = new Bogus.Randomizer();
            var fakerNameDataset = new Bogus.DataSets.Name("en");

            for (var i = 0; i < ITEMS_COUNT; i++)
            {
                persons.Add(new Person(
                                fakerNameDataset.FirstName(),
                                fakerNameDataset.LastName(),
                                fakerRandomizer.Int(1900, 2000) * 10000 + fakerRandomizer.Int(1, 12) * 100 + fakerRandomizer.Int(1, 31)));
            }

            var sw = new Stopwatch();

            sw.Reset();

            // Ricerca su indice year

            const int YEAR_TO_SEARCH_FOR = 1971;

            if (persons[INDEX_NAME_YEAR][YEAR_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_YEAR}', ricerca su valore {YEAR_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_YEAR][YEAR_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            sw.Restart();

            // Ricerca su indice month

            const string MONTH_TO_SEARCH_FOR = "Nov";

            if (persons[INDEX_NAME_MONTH][MONTH_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_MONTH}', ricerca su valore {MONTH_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_MONTH][MONTH_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            // Ricerca su indice day

            sw.Restart();

            const int DAY_TO_SEARCH_FOR = 17;

            if (persons[INDEX_NAME_DAY][DAY_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_DAY}', ricerca su valore {DAY_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_DAY][DAY_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");

            // Ricerca su indice name

            sw.Restart();

            const string NAME_TO_SEARCH_FOR = "Lawrence";

            if (persons[INDEX_NAME_NAME][NAME_TO_SEARCH_FOR].Any())
            {
                _output.WriteLine($"Indice '{INDEX_NAME_NAME}', ricerca su valore {NAME_TO_SEARCH_FOR}, trovati {persons[INDEX_NAME_NAME][NAME_TO_SEARCH_FOR].Count} item");
            }
            else
            {
                _output.WriteLine("Nessuno.");
            }

            _output.WriteLine($"Tempo impiegato: {sw.ElapsedMilliseconds} msec\n");
        }
Esempio n. 16
0
        public Record()
        {
            var randombogus = new Bogus.DataSets.Name.Gender();

            var randomName    = new Bogus.DataSets.Name("en");
            var randomPhone   = new Bogus.DataSets.PhoneNumbers("en");
            var randomAddress = new Bogus.DataSets.Address("en");

            Random rand = new Random();

            if (rand.NextDouble() >= 0.5)
            {
                Sex         = "female";
                randombogus = (Bogus.DataSets.Name.Gender) 1;
            }
            else
            {
                Sex         = "male";
                randombogus = (Bogus.DataSets.Name.Gender) 0;
            }

            //generate race
            //source for stats: 2019 US census beaurau estimates
            var racerand = rand.NextDouble();

            if (racerand <= 0.6)
            {
                Race = "white";
            }
            else if (racerand > 0.6 && racerand <= 0.78)
            {
                Race = "hispanic (of any race)";
            }
            else if (racerand > 0.78 && racerand <= 0.91)
            {
                Race = "black";
            }

            else if (racerand > 0.91 && racerand <= 0.97)
            {
                Race = "asian";
            }
            else if (racerand > 0.97 && racerand <= 0.98)
            {
                Race = "native american or alaskan native";
            }
            else if (racerand > 0.98 && racerand <= 0.985)
            {
                Race = "native hawaiian or other pacific islander";
            }
            else
            {
                Race = "two or more races";
            }


            if (Sex == "male")
            {
                //The multiplier makes taller people slightly heavier. Someone 1.9 meters will be about  8% heavier than someone that's 1.5 meters, compared to without the bonus. Make divisor smaller to make effect more extreme
                HeightInMeters = NormalDistribution.Random(1.8, 0.1);
                //if (HeightInMeters < 2.0) { var heightWeightMultiplier = (1 + (HeightInMeters - 2.0) / 4.0); }
                //else { var heightWeightMultiplier = (2.0 + ((HeightInMeters -2.0)  / 4.0)); }
                Weight    = NormalDistribution.Random(86, 18); //average values and stddev. source: google
                Waistline = 40 + ((Weight - 86) / 4);          //you gain 1in / 4kg
            }
            else
            {
                HeightInMeters = NormalDistribution.Random(1.65, 0.1);
                //if (HeightInMeters < 2.0) { var heightWeightMultiplier = (1 + (HeightInMeters - 2.0) / 4.0); }
                //else { var heightWeightMultiplier = (2.0 + ((HeightInMeters - 2.0) / 4.0)); }

                Weight    = NormalDistribution.Random(78, 14);
                Waistline = 36 + ((Weight - 86) / 4); //in meters. since 1kg causes +/- 0.01m waistline. average just happens to be 1.0
            }

            double weightHeightCorrelation = (.5) * ((HeightInMeters * 100) - 180);

            Weight += weightHeightCorrelation;


            //convert meters to ft/in
            var inchFeet = (HeightInMeters / 0.3048);

            HeightFeet   = (int)inchFeet;
            HeightInches = Math.Floor(Math.Round((inchFeet - HeightFeet) / 0.0833));

            //convert kg to pounds
            WeightInLb = Weight * 2.20462;


            FirstName   = randomName.FirstName(randombogus);
            LastName    = randomName.LastName();
            PhoneNumber = randomPhone.PhoneNumber();
            Address     = randomAddress.StreetAddress();

            Random   gen         = new Random();
            double   probability = gen.NextDouble();
            DateTime start       = new DateTime(DateTime.Today.Year - 85, 1, 1);

            int rangeMax; int rangeMin;

            if (probability <= 0.15)
            {
                rangeMin = 0; rangeMax = (85 * 365 - 65 * 365);
            }
            else
            {
                rangeMin = 21 * 365;  rangeMax = 65 * 365;
            }

            DateOfBirth = start.AddDays(gen.Next(rangeMin, rangeMax));
            Age         = DateTime.Today.Year - DateOfBirth.Year;
            if (DateOfBirth.Date > DateTime.Today.AddYears(-Age))
            {
                Age--;
            }

            BMI = Weight / Math.Pow(HeightInMeters, 2);
        }
Esempio n. 17
0
        public IEnumerable <string> Get()
        {
            var name = new Bogus.DataSets.Name();

            return(new string[] { "name", name.FindName() });
        }