Example #1
0
        private static void VerifyWordCount(Question2TestOutput output, string word, int expectedCount, int factor = 1)
        {
            int factoredExpectedCount = expectedCount * factor;

            if (!output.CheckWordCount(word, factoredExpectedCount))
            {
                Assert.Fail($"The word '{word}' should appear {factoredExpectedCount} times");
            }
        }
Example #2
0
        public void TestQuestionTwoSingle()
        {
            var output = new Question2TestOutput();

            using (var slowReader = new SlowCharacterReader())
            {
                DeveloperImplementation.RunQuestionTwo(new ICharacterReader[] { slowReader }, output);
                VerifyQuestionTwoSingle(output);
            }
        }
Example #3
0
        public async Task TestQuestionTwoSingleAsync()
        {
            var output = new Question2TestOutput();

            using (var slowReader = new SlowCharacterReader())
            {
                await DeveloperImplementation.RunQuestionTwo(new ICharacterReader[] { slowReader }, output, CancellationToken.None);

                VerifyQuestionTwoSingle(output);
            }
        }
        [Test, Timeout(220000)] // Timeout parameter value changed from 120000 to 220000 by Kostas.
        public async Task TestQuestionTwoMultipleAsync()
        {
            var output = new Question2TestOutput();

            using (var slowReader1 = new SlowCharacterReader())
                using (var slowReader2 = new SlowCharacterReader())
                    using (var slowReader3 = new SlowCharacterReader())
                    {
                        await DeveloperImplementation.RunQuestionTwo(new ICharacterReader[] { slowReader1, slowReader2, slowReader3 }, output);

                        VerifyQuestionTwoMultiple(output);
                    }
        }
Example #5
0
        protected void VerifyQuestionTwoSingle(Question2TestOutput output)
        {
            string validationErrors = output.ValidationErrors;

            if (!string.IsNullOrEmpty(validationErrors))
            {
                Assert.Fail(validationErrors);
            }
            Assert.AreEqual(76, output.Count, "Result count is incorrect");
            VerifyWordCount(output, "book", 2);
            VerifyWordCount(output, "and", 4);
            VerifyWordCount(output, "rabbit", 1);
        }