Beispiel #1
0
        public void TestNewQuestionCheckAnswerAndGetSummary()
        {
            var testSm = new QuestionSessionManager(new TestWeirdDatabase());



            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(i < 5);
                var question = testSm.GetNewQuestion();

                if (i == 0)
                {
                    var questionAnswer = testSm.CheckAnswer(question.Id, 2);
                    Assert.AreEqual(questionAnswer.IsCorrect, false);
                    Assert.AreEqual(questionAnswer.Explanation, "One plus one is two");
                }


                if (i == 1)
                {
                    var questionAnswer = testSm.CheckAnswer(question.Id, 2);
                    Assert.AreEqual(questionAnswer.IsCorrect, false);
                    Assert.AreEqual(questionAnswer.Explanation, "(often be absorbed in) take up the attention of(someone); interest greatly");
                }

                if (i == 2)
                {
                    var questionAnswer = testSm.CheckAnswer(question.Id, 2);
                    Assert.AreEqual(questionAnswer.IsCorrect, true);
                    Assert.AreEqual(questionAnswer.Explanation, "Accuse of");
                }


                if (i == 3)
                {
                    var questionAnswer = testSm.CheckAnswer(question.Id, 2);
                    Assert.AreEqual(questionAnswer.IsCorrect, true);
                    Assert.AreEqual(questionAnswer.Explanation, "“It’s” is only ever used when short for “it is”. “Its” indicates something belonging to something that isn’t masculine or feminine (like “his” and “hers”, but used when you’re not talking about a person).");
                }



                if (question.IsLastQuestion)
                {
                    var questionSummary = testSm.GetSummary();
                    Assert.AreEqual(questionSummary.TotalQuestions, 4);
                    Assert.AreEqual(questionSummary.CorrectQuestions, 2);
                    break;
                }
            }
        }
Beispiel #2
0
        private void LoadQuestion()
        {
            DisableCheck();

            if (_isLastQuestion)
            {
                var summary = _testSm.GetSummary();
                _button.IsVisible      = false;
                _stackLayout.IsVisible = false;
                _header.Text           = "Score " + summary.CorrectQuestions + "/" +
                                         summary.TotalQuestions + " - " + summary.SummaryMessage;
            }
            else
            {
                _question       = _testSm.GetNewQuestion();
                _isLastQuestion = _question.IsLastQuestion;
                _header.Text    = _question.Text;

                _stackLayout.Children?.Clear();


                AddButtons(_stackLayout, _question.Answers);
            }
        }