Ejemplo n.º 1
0
        public void PopulatePreviousHintAndAnswers()
        {
            var model = new SpellingModel();

            model.table = SpellingController.Load("test_words.csv");
            model.Setup();
            model.Populate();
            var prompts = model.promptAndAnswers;

            Assert.AreEqual("PART", prompts[0].answerText);
            Assert.AreEqual("TRAP", prompts[1].answerText);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[0]);
            model.Hint();
            Assert.AreEqual("P", prompts[0].answerTexts[0]);
            prompts[1].ShowAnswer(true);
            Assert.AreEqual("T", prompts[1].answerTexts[0]);
            model.UpdateAnswer();
            Assert.AreEqual(true, prompts[1].isAnswerVisible);
            Assert.AreEqual(1, model.answerCount);
            for (int round = 0; round < 2; round++)
            {
                model.contentIndex = 1;
                model.Populate();
                prompts = model.promptAndAnswers;
                Assert.AreEqual("CREST", prompts[0].answerText);
                Assert.AreEqual("ERECTS", prompts[1].answerText);
                Assert.AreEqual(model.empty, prompts[0].answerTexts[0]);
                Assert.AreEqual(model.empty, prompts[1].answerTexts[0]);
                Assert.AreEqual(false, model.isLetterSelects[0]);
                model.Toggle(0);
                Assert.AreEqual(true, model.isLetterSelects[0]);
                model.contentIndex = 0;
                model.Populate();
                prompts = model.promptAndAnswers;
                Assert.AreEqual("PART", prompts[0].answerText);
                Assert.AreEqual("TRAP", prompts[1].answerText);
                Assert.AreEqual("P", prompts[0].answerTexts[0]);
                Assert.AreEqual("T", prompts[1].answerTexts[0]);
                model.UpdateAnswer();
                Assert.AreEqual(true, prompts[1].isAnswerVisible);
                Assert.AreEqual(1, model.answerCount);
                Assert.AreEqual(false, model.isLetterSelects[0]);
                model.Toggle(0);
                Assert.AreEqual(true, model.isLetterSelects[0]);
            }
        }
Ejemplo n.º 2
0
        private void UpdateButtons()
        {
            buttons.Update();
            int letterButtonIndex = DataUtil.IndexOf(view.letterButtons, buttons.view.target);

            if (0 <= letterButtonIndex)
            {
                model.Toggle(letterButtonIndex);
            }
            else if (view.exitButton == buttons.view.target)
            {
                model.Exit();
            }
            else if (view.hintButton == buttons.view.target)
            {
                model.Hint();
            }
        }
Ejemplo n.º 3
0
        public void HintNextLetterAndScoreDown20()
        {
            var model = new SpellingModel();

            model.table = SpellingController.Load("test_words.csv");
            model.Setup();
            model.Populate();
            int score   = model.score;
            var prompts = model.promptAndAnswers;

            Assert.AreEqual("PART", prompts[0].answerText);
            Assert.AreEqual("TRAP", prompts[1].answerText);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[1]);
            Assert.AreEqual(model.empty, prompts[1].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[1].answerTexts[1]);
            model.Hint();
            Assert.AreEqual("P", prompts[0].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[1]);
            Assert.AreEqual(model.empty, prompts[1].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[1].answerTexts[1]);
            Assert.AreEqual(score + model.scorePerHint, model.score);
            model.Hint();
            Assert.AreEqual("P", prompts[0].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[1]);
            Assert.AreEqual("T", prompts[1].answerTexts[0]);
            Assert.AreEqual(model.empty, prompts[1].answerTexts[1]);
            Assert.AreEqual(score + 2 * model.scorePerHint, model.score);
            prompts[1].ShowAnswer(true);
            prompts[2].ShowAnswer(true);
            prompts[3].ShowAnswer(true);
            model.UpdateAnswer();
            Assert.AreEqual(false, model.isAnswerAllNow);
            Assert.AreEqual(3, model.answerCount);
            model.Hint();
            Assert.AreEqual(score + 3 * model.scorePerHint, model.score);
            Assert.AreEqual("P", prompts[0].answerTexts[0]);
            Assert.AreEqual("A", prompts[0].answerTexts[1]);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[2]);
            Assert.AreEqual(model.empty, prompts[0].answerTexts[3]);
            model.Hint();
            Assert.AreEqual("R", prompts[0].answerTexts[2]);
            Assert.AreEqual(score + 4 * model.scorePerHint, model.score);
            model.Hint();
            Assert.AreEqual("T", prompts[0].answerTexts[3]);
            Assert.AreEqual(score + 5 * model.scorePerHint, model.score);
            model.UpdateAnswer();
            Assert.AreEqual(4, model.answerCount);
            Assert.AreEqual(true, model.isAnswerAllNow);
            model.Hint();
            Assert.AreEqual(score + 5 * model.scorePerHint, model.score);
        }