void SetParagraphSize(IWebDriver driver, ParagraphSize paragraphSize) { IEnumerable <IWebElement> rdoSizeParagraphs = driver.FindElements(By.CssSelector("input[name=plenght]")) .OrderBy(x => x.GetAttribute("value")); rdoSizeParagraphs.ElementAt((int)paragraphSize - 1).Click(); }
public static string GetRandomParagraph(ParagraphSize size) { switch (size) { case ParagraphSize.Short: var paragraph = string.Empty; var sentenceCount = Utils.Random.Next(3, 4); for (var i = 0; i < sentenceCount; i++) { var sentence = Setences.GetRandomSentence(WordSize.Any); paragraph += string.Concat(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(sentence), ". "); } return paragraph; case ParagraphSize.Medium: return string.Concat( GetRandomParagraph(ParagraphSize.Short), GetRandomParagraph(ParagraphSize.Short)); case ParagraphSize.Long: return string.Concat( GetRandomParagraph(ParagraphSize.Medium), GetRandomParagraph(ParagraphSize.Medium)); case ParagraphSize.VeryLong: return string.Concat( GetRandomParagraph(ParagraphSize.Long), GetRandomParagraph(ParagraphSize.Long)); case ParagraphSize.Any: default: var randomSize = Utils.GetRandomEnumValue<ParagraphSize>(); return GetRandomParagraph(randomSize); } }
public static string GetRandomParagraphs(ParagraphSize size, int count) { var result = new StringBuilder(); for (var i = 0; i < count; i++) { var paragraph = Paragraphs.GetRandomParagraph(size); result.Append(paragraph.Trim() + "\n\n"); } return(result.ToString().Trim()); }
public static string GetRandomParagraphs(ParagraphSize size, int count) { var result = new StringBuilder(); for (var i = 0; i < count; i++) { var paragraph = Paragraphs.GetRandomParagraph(size); result.Append(paragraph.Trim() + "\n\n"); } return result.ToString().Trim(); }
public static string GetRandomParagraph(ParagraphSize size) { switch (size) { case ParagraphSize.Short: var paragraph = string.Empty; var sentenceCount = Utils.Random.Next(3, 4); for (var i = 0; i < sentenceCount; i++) { var sentence = Setences.GetRandomSentence(WordSize.Any); paragraph += string.Concat(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(sentence), ". "); } return(paragraph); case ParagraphSize.Medium: return(string.Concat( GetRandomParagraph(ParagraphSize.Short), GetRandomParagraph(ParagraphSize.Short))); case ParagraphSize.Long: return(string.Concat( GetRandomParagraph(ParagraphSize.Medium), GetRandomParagraph(ParagraphSize.Medium))); case ParagraphSize.VeryLong: return(string.Concat( GetRandomParagraph(ParagraphSize.Long), GetRandomParagraph(ParagraphSize.Long))); case ParagraphSize.Any: default: var randomSize = Utils.GetRandomEnumValue <ParagraphSize>(); return(GetRandomParagraph(randomSize)); } }
public string GenerateLoremIpsum(bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize paragraphSize) { return(base.TryForAllSources(s => s.GenerateLoremIpsum(startWithLoremIpsum, quantityOfParagraphs, paragraphSize))); }
public void GenerateLoremIpsum_QuantityOfParagraphs(bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize size) { var text = lorem.GenerateLoremIpsum(startWithLoremIpsum, quantityOfParagraphs, size); var paragraphs = text.Split("\n", StringSplitOptions.RemoveEmptyEntries); Assert.That(paragraphs.Length, Is.EqualTo(quantityOfParagraphs)); }
public int WriteLoremFile(bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize paragraphSize) { var iterations = 0; using (var fileStream = new StreamWriter(_filePath, true, Encoding.UTF8)) { var totalBytesWritten = 0L; var bytesInBuffer = 0L; while (true) { string lorem = _loremIpsumService.GenerateLoremIpsum(startWithLoremIpsum, quantityOfParagraphs, paragraphSize); long newBytes = _byteCounterService.CountBytes(lorem); if (totalBytesWritten + newBytes > _maxFileSizeInBytes) { fileStream.Flush(); break; } if (bytesInBuffer + newBytes > _bufferSizeInBytes) { fileStream.Flush(); bytesInBuffer = 0; } totalBytesWritten += newBytes; bytesInBuffer += newBytes; fileStream.Write(lorem); iterations++; } } return(iterations); }
public string GenerateLoremIpsum(bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize paragraphSize) { var quantityOfPhrasesPerParagraph = paragraphSize == ParagraphSize.Long ? 9 : paragraphSize == ParagraphSize.Medium ? 6 : 3; var paragraphs = Phrases .Repeat() .Prepend(startWithLoremIpsum ? Lorem : string.Empty) .Batch(quantityOfPhrasesPerParagraph, phrases => string.Join(" ", phrases)) .Take(quantityOfParagraphs); return(string.Join("\n", paragraphs)); }
void SetConfigurations(IWebDriver driver, bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize paragraphSize) { SetStartWithLorem(driver, startWithLoremIpsum); SetParagraphSize(driver, paragraphSize); SetQuantityOfParagraphs(driver, quantityOfParagraphs); }
public string GenerateLoremIpsum(bool startWithLoremIpsum, int quantityOfParagraphs, ParagraphSize paragraphSize) { using (IWebDriver driver = _webDriverFactory.GetDriver()) { driver.Navigate().GoToUrl(_siteURL); SetConfigurations(driver, startWithLoremIpsum, quantityOfParagraphs, paragraphSize); return(GetOutputtedLorem(driver)); } }