예제 #1
0
        public void quiz_file_not_found()
        {
            using (var sw = new StringWriter())
            {
                using (var response1 = new StringReader("no_file" + Environment.NewLine))
                {
                    Console.SetOut(sw);
                    Console.SetIn(response1);

                    Quiz quizTest = new Quiz();
                    quizTest.Calculate(quizTest);

                    var result = sw.ToString();
                    Assert.IsTrue(result.Contains("File does not exist"));
                }
            }
        }
예제 #2
0
        public void quiz_input_letters_instead_of_numbers()
        {
            using (var sw = new StringWriter())
            {
                using (var response1 = new StringReader("C:/Users/Christian/Desktop/ChrisitianThompsonAvaSure/repo/quizAvasure/questionFile.txt" + Environment.NewLine + "hi" + Environment.NewLine + "ava" + Environment.NewLine + "sure" + Environment.NewLine))
                {
                    Console.SetOut(sw);
                    Console.SetIn(response1);

                    Quiz quizTest = new Quiz();
                    quizTest.Calculate(quizTest);

                    //confirms no errors were thrown, only incorrect answers
                    Assert.IsTrue(quizTest.inputAnswers[0] == 0 && quizTest.inputAnswers[1] == 0 && quizTest.inputAnswers[2] == 0);
                    Assert.IsTrue(quizTest.score == 0);
                }
            }
        }
예제 #3
0
        public void quiz_0_out_of_3()
        {
            using (var sw = new StringWriter())
            {
                using (var response1 = new StringReader("C:/Users/Christian/Desktop/ChrisitianThompsonAvaSure/repo/quizAvasure/questionFile.txt" + Environment.NewLine + "1" + Environment.NewLine + "3" + Environment.NewLine + "2" + Environment.NewLine))
                {
                    Console.SetOut(sw);
                    Console.SetIn(response1);

                    Quiz quizTest = new Quiz();
                    quizTest.Calculate(quizTest);

                    //confirms all 3 were incorrect
                    Assert.IsTrue(quizTest.inputAnswers[0] == 0 && quizTest.inputAnswers[1] == 0 && quizTest.inputAnswers[2] == 0);
                    Assert.IsTrue(quizTest.score == 0);
                }
            }
        }