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
        void OnButtonClicked(object sender, EventArgs e)
        {
            if (_contentViewContent.IsVisible)
            {
                _contentViewContent.IsVisible = false;


                LoadQuestion();

                _contentViewContent.Text            = "";
                _contentViewContent.BackgroundColor = default(Color);
                _button.Text = "Check";
            }

            else
            {
                _contentViewContent.IsVisible = true;

                foreach (var child in _stackLayout.Children)
                {
                    Button someButton = child as Button;
                    if (someButton != null)
                    {
                        someButton.IsEnabled = false;
                    }
                }


                int selectItemId   = int.Parse(_selectedId);
                var questionAnswer = _testSm.CheckAnswer(_question.Id, selectItemId);

                _contentViewContent.Text = questionAnswer.Explanation;

                if (questionAnswer.IsCorrect)
                {
                    _contentViewContent.BackgroundColor = Color.FromHex("#dff0d8");
                    //Border color???  _contentViewContent. = Color.FromHex("#d0e9c6");
                    _contentViewContent.TextColor = Color.FromHex("#3c763d");
                }
                else
                {
                    //border ??#ebcccc
                    _contentViewContent.BackgroundColor = Color.FromHex("#f2dede");
                    _contentViewContent.TextColor       = Color.FromHex("#a94442");
                }


                _button.Text = "Continue";
            }
        }