예제 #1
0
        public void Quiz100PercentTest(double per, GradeLetter letter)
        {
            var answer = new Answer()
            {
                CorrectAnswer = 1, UserInput = per
            };
            var gradeScore = new QuizScorer(new AnswerScorerPercent());
            var grade      = gradeScore.CalculateScore(new [] { answer });

            Assert.AreEqual(letter, grade.GradeLetter);
        }
예제 #2
0
        public void Quiz50RightIs50()
        {
            var quizResult = quiz.CreateQuiz(10);

            var count = quizResult.Answers.Count;
            var half  = count / 2;

            foreach (var answer in quizResult.Answers.Take(half))
            {
                answer.UserInput = answer.CorrectAnswer;
            }

            var score  = new QuizScorer(new AnswerScorerPercent());
            var result = score.CalculateScore(quizResult.Answers);

            Assert.AreEqual(0.5, result.Percent);
        }