public void ParagraphByChars() { Config.Locale = "zh-TW"; const int defaultChars = 256 + 1; // +1 for period var paragraph = Lorem.ParagraphByChars(); Assert.AreEqual(defaultChars, paragraph.Length); var checkCount = 0; Assert.IsTrue(SupplementalWordList.Contains("abbas")); Assert.IsTrue(SupplementalWordList.Contains("cum")); var wordListAsLower = WordList.Select(w => w.ToLower()); foreach (var word in paragraph.ToWordList().Take(paragraph.Length - 1)) // last word may be truncated or padded { if (paragraph.ToLower().EndsWith(word + Lorem.PunctuationPeriod())) { // don't check last word as it might be truncated or padded return; } // but check all others checkCount++; Assert.IsTrue(wordListAsLower.Contains(word.ToLower()), $"{nameof(Config.Locale)} '{Config.Locale}'. Missing word is '{word}'. {nameof(paragraph)} is '{paragraph}'. {nameof(wordListAsLower)} is '{string.Join('|', wordListAsLower.ToArray())}'" ); } Assert.Greater(checkCount, 10); }
public void ParagraphByChars_With_Supplementary_List() { var paragraph = Lorem.ParagraphByChars(supplemental: true); foreach (var word in paragraph.ToWordList()) { if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { return; } } Assert.Fail("ParagraphByChars() does not consider supplementary list."); }
public void Words_Uses_Words_From_Supplementary_List() { var words = Lorem.Words(42, supplemental: true); foreach (var word in words) { if (SupplementalWordList.Contains(word) || !JointWords.Contains(word)) { return; } } Assert.Fail("Words() does not consider supplementary words."); }
public void ParagraphByChars_Does_Not_End_With_Space_Dot() { RandomNumber.ResetSeed(42); var maxWordLength = 0; _ = WordList.All(x => { maxWordLength = Math.Max(maxWordLength, x.Length); return(true); }); _ = SupplementalWordList.All(x => { maxWordLength = Math.Max(maxWordLength, x.Length); return(true); }); const int startValue = 50; var charCount = startValue; while (charCount++ <= startValue + maxWordLength) { var paragraph = Lorem.ParagraphByChars(43); Assert.IsFalse(paragraph.EndsWith(" .")); } }
public void Paragraph_Use_Supplementary_List() { var paragraph = Lorem.Paragraph(supplemental: true); var checkCount = 0; foreach (var word in paragraph.ToWordList()) { checkCount++; if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { return; } } Assert.AreEqual(checkCount, paragraph.ToWordList().Count()); Assert.Fail("Paragraph() does not consider supplementary list."); }
public void Questions_With_Words_From_Supplementary_List() { var questions = Lorem.Questions(supplemental: true); var supplementalWordCount = 0; foreach (var question in questions) { foreach (var word in question.ToWordList()) { if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { supplementalWordCount++; } } } Assert.Greater(supplementalWordCount, 0); }
public void Question_With_Supplementary_List() { const int wordCount = 50; var question = Lorem.Question(wordCount, supplemental: true); var checkCount = 0; foreach (var word in question.ToWordList()) { checkCount++; if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { return; } } Assert.AreEqual(wordCount, checkCount); Assert.Fail("Question() does not consider supplementary words."); }
public void Paragraphs_Without_Supplemental() { var paragraphs = Lorem.Paragraphs(supplemental: false); var checkCount = 0; foreach (var paragraph in paragraphs) { foreach (var word in paragraph.ToWordList()) { checkCount++; if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { Assert.Fail("Paragraphs() shouldn't consider supplementary list."); } } } Assert.Greater(checkCount, paragraphs.Count()); }
public void Sentences_With_Words_From_Supplementary_List() { var sentences = Lorem.Sentences(42, true); var checkCount = 0; foreach (var sentence in sentences) { foreach (var word in sentence.ToWordList()) { if (SupplementalWordList.Contains(word)) { return; } checkCount++; } } Assert.Greater(checkCount, 0); Assert.Fail($"Locale {Locale}. Sentences() does not make use of supplementary words."); }
public void Sentence_With_Words_From_Supplementary_List() { RandomNumber.ResetSeed(42); const int wordCount = 42; var sentence = Lorem.Sentence(wordCount, supplemental: true).ToLower(); var checkCount = 0; foreach (var word in sentence.ToWordList()) { if (!JointWords.Contains(word) && SupplementalWordList.Contains(word)) { return; } checkCount++; } Assert.Greater(checkCount, 0); Assert.Fail("Sentence() does not consider supplementary words."); }
public void Words_With_WordCount() { const int wordCount = 42; var words = Lorem.Words(wordCount); Assert.AreEqual(wordCount, words.Count()); Assert.AreEqual(0, words.Count(x => string.IsNullOrWhiteSpace(x))); foreach (var word in words) { if (JointWords.Contains(word)) { continue; } Assert.True(WordList.Contains(word), $"Locale '{Locale}'. Word missing from word list '{word}'" ); Assert.False(SupplementalWordList.Contains(word)); } }