예제 #1
0
파일: LoremTests.cs 프로젝트: RimuTec/Faker
        public void Question_With_Default_Values()
        {
            var question = Lorem.Question();

            Assert.AreEqual(4, question.Split(Lorem.PunctuationSpace()).Length);
            Assert.IsTrue(question.EndsWith(Lorem.PunctuationQuestionMark()));
        }
예제 #2
0
파일: LoremTests.cs 프로젝트: RimuTec/Faker
        public void Question_Without_Supplementary_List()
        {
            const int wordCount  = 50;
            var       question   = Lorem.Question(wordCount);
            var       checkCount = 0;

            foreach (var word in question.ToWordList())
            {
                checkCount++;
                Assert.IsTrue(WordList.Contains(word),
                              $"Locale '{Locale}'. Missing word is '{word}'"
                              );
            }
            Assert.AreEqual(wordCount, checkCount);
        }
예제 #3
0
        public void Lorem_Methods()
        {
            Func <object>[] actions = new[]
            {
                new Func <object>(() => Lorem.Character()),
                new Func <object>(() => Lorem.Characters()),
                new Func <object>(() => Lorem.Multibyte()),
                new Func <object>(() => Lorem.Paragraph()),
                new Func <object>(() => Lorem.ParagraphByChars()),
                new Func <object>(() => Lorem.Paragraphs()),
                new Func <object>(() => Lorem.Question()),
                new Func <object>(() => Lorem.Questions()),
                new Func <object>(() => Lorem.Sentence()),
                new Func <object>(() => Lorem.Sentences()),
                new Func <object>(() => Lorem.Word()),
                new Func <object>(() => Lorem.Words()),
            };

            bool success           = true;
            int  totalExecutions   = 0;
            int  successExecutions = 0;
            int  failedExecutions  = 0;

            foreach (Func <object> action in actions)
            {
                foreach (string loc in _localizations)
                {
                    ++totalExecutions;

                    if (!TryCatch(action, loc))
                    {
                        success = false;
                        ++failedExecutions;
                    }
                    else
                    {
                        ++successExecutions;
                    }
                }
            }

            Console.WriteLine($"{failedExecutions} of {totalExecutions} executions failed");

            Assert.IsTrue(success);
            Assert.AreEqual(totalExecutions, successExecutions);
        }
예제 #4
0
파일: LoremTests.cs 프로젝트: RimuTec/Faker
        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.");
        }
예제 #5
0
파일: LoremTests.cs 프로젝트: RimuTec/Faker
        public void Question_With_Invalid_RandomWordsToAdd()
        {
            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => Lorem.Question(wordCount: -1));

            Assert.AreEqual("Must be equal to or greater than zero. (Parameter 'wordCount')", ex.Message);
        }
예제 #6
0
파일: LoremTests.cs 프로젝트: RimuTec/Faker
        public void Question_With_Zero_Length_Returns_Empty_String()
        {
            var question = Lorem.Question(0);

            Assert.AreEqual(string.Empty, question);
        }