public void CriarContaUsuario() { Sexo sexo = enumHelper.EnumAleatorio <Sexo>(); Gerador gera = new Gerador(); string firsName = gera.GeraNome(sexo); string lastName = gera.GeraDadosAleatorios("Sobrenomes.txt"); string email = Encoding.ASCII.GetString(Encoding.GetEncoding("Cyrillic") .GetBytes($"{firsName}.{lastName}.{IntegerHelper.Random(111,999)}@hotmail.com")).ToLower().Trim(); string password = IntegerHelper.Random(11111, 99999).ToString(); string monthOfBirth = enumHelper.EnumAleatorio <MesesAno>().ObterDescricao(); int dayOfBirth = IntegerHelper.Random(1, 29); int yearOfBirth = IntegerHelper.Random(1980, 2000); int zipPostalCode = IntegerHelper.Random(11111, 99999); string phoneNumber = $"({IntegerHelper.Random(44, 47)}) {IntegerHelper.Random(1111,9999)}-{IntegerHelper.Random(1111, 9999)}"; string city = gera.GeraDadosAleatorios("Cidades.txt"); string state = gera.GeraDadosAleatorios("Estados.txt"); string address = $"{gera.GeraDadosAleatorios("Logradouros.txt")} {lastName}, nº {IntegerHelper.Random(10,999)}"; cartBuilder .ProceedToCheckoutSummaryButtonClick() .EmailCreate(email) .CreateAccountButtonClick(); Thread.Sleep(2000); if (sexo == Sexo.Masculino) { cartBuilder .Mr.Click(); } else { cartBuilder .Mrs.Click(); } cartBuilder .FirstName(firsName) .LastName(lastName) .Password(password) .DayOfBirth(dayOfBirth) .MonthOfBirth(monthOfBirth) .YearOfBirth(yearOfBirth) .FirstLineAddress(address) .City(city) .State(state) .ZipPostalCode(zipPostalCode.ToString()) .MobilePhone(phoneNumber) .RegisterButtonClick(); Assert.IsTrue(wait.Until(t => cartBuilder.ProceedToCheckoutAddressButton.Displayed)); }
public string GeraDadosAleatorios(string path) { string valorGerado; List <string> linhasL = new List <string>(); var directory = $@"{Directory.GetCurrentDirectory()}\MyStore\Arquivos\"; using (StreamReader reader = new StreamReader(directory + path, Encoding.GetEncoding("iso-8859-1"))) { string Linhas = string.Empty; while ((Linhas = reader.ReadLine()) != null) { linhasL.Add(Linhas); } valorGerado = linhasL[IntegerHelper.Random(0, linhasL.Count)]; } return(valorGerado); }