Esempio n. 1
0
        public void CheckCalculationOperator()
        {
            GameAnswer answer = new GameAnswer ();
            answer.Correct = "+ | -";
            answer.CheckExpression = "[+*-/]";
            answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;

            Assert.AreEqual (true, answer.CheckAnswer ("+ i -"));
            Assert.AreEqual (true, answer.CheckAnswer ("+ and -"));
            Assert.AreEqual (true, answer.CheckAnswer ("+ -"));
            Assert.AreEqual (true, answer.CheckAnswer ("+-"));

            Assert.AreEqual (false, answer.CheckAnswer ("- +"));
        }
Esempio n. 2
0
        public void CheckPuzzlePercentage()
        {
            GameAnswer answer = new GameAnswer ();

            answer.Correct = "10";
            answer.CheckExpression = "[0-9]+";

            Assert.AreEqual (true, answer.CheckAnswer ("10%"));
            Assert.AreEqual (true, answer.CheckAnswer ("10 %"));
            Assert.AreEqual (true, answer.CheckAnswer ("10"));

            answer.Correct = "9";
            Assert.AreEqual (true, answer.CheckAnswer ("9%"));
            Assert.AreEqual (true, answer.CheckAnswer ("9 %"));
            Assert.AreEqual (true, answer.CheckAnswer ("9"));
        }
Esempio n. 3
0
        public void CheckPuzzleBuildTriangle()
        {
            GameAnswer answer = new GameAnswer ();

            answer.Correct = "A | B | C";
            answer.CheckExpression = "[ABCDF]";
            answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;

            Assert.AreEqual (true, answer.CheckAnswer ("A B C"));
            Assert.AreEqual (true, answer.CheckAnswer ("C B A"));
            Assert.AreEqual (true, answer.CheckAnswer ("B C A"));
            Assert.AreEqual (true, answer.CheckAnswer ("A B C"));
            Assert.AreEqual (true, answer.CheckAnswer ("C A B"));
            Assert.AreEqual (true, answer.CheckAnswer ("a b c"));

            Assert.AreEqual (false, answer.CheckAnswer ("B C C"));
            Assert.AreEqual (false, answer.CheckAnswer ("B C"));
            Assert.AreEqual (false, answer.CheckAnswer ("BC"));
        }
Esempio n. 4
0
 protected Game()
 {
     answer     = new GameAnswer();
     containers = new List <Toolkit.Container> ();
     difficulty = GameDifficulty.Medium;
 }
Esempio n. 5
0
 protected Game()
 {
     answer = new GameAnswer ();
     containers = new List <Toolkit.Container> ();
     difficulty = GameDifficulty.Medium;
 }
Esempio n. 6
0
        public void CheckPuzzleTimeNowAnswer()
        {
            GameAnswer answer = new GameAnswer ();
            answer.Correct = "10 PM";
            answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;

            Assert.AreEqual (true, answer.CheckAnswer ("10 PM"));
            Assert.AreEqual (true, answer.CheckAnswer ("10 pm"));
            Assert.AreEqual (true, answer.CheckAnswer ("10pm"));
            Assert.AreEqual (true, answer.CheckAnswer ("10Pm"));
            Assert.AreEqual (true, answer.CheckAnswer (" 10Pm "));

            Assert.AreEqual (false, answer.CheckAnswer ("10 P"));
            Assert.AreEqual (false, answer.CheckAnswer ("10"));
        }
Esempio n. 7
0
        public void Trim()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes = GameAnswerCheckAttributes.None;
            answer.Correct = "icon";
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (false, answer.CheckAnswer (" icon "));

            answer.CheckAttributes = GameAnswerCheckAttributes.Trim;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (true, answer.CheckAnswer (" icon "));

            answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (false, answer.CheckAnswer (" icon "));

            answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (true, answer.CheckAnswer (" icon "));
        }
Esempio n. 8
0
        public void TwoNumbersAnswer()
        {
            GameAnswer answer = new GameAnswer ();
            answer.Correct = "10 | 20";
            answer.CheckExpression = "[0-9]+";
            answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;

            // Right answers
            Assert.AreEqual (true, answer.CheckAnswer ("10 and 20"));
            Assert.AreEqual (true, answer.CheckAnswer ("10 i 20"));
            Assert.AreEqual (true, answer.CheckAnswer ("10 y 20"));
            Assert.AreEqual (true, answer.CheckAnswer ("10 20"));
            Assert.AreEqual (true, answer.CheckAnswer (" 10 20 "));

            Assert.AreEqual (true, answer.CheckAnswer ("20 and 10"));
            Assert.AreEqual (true, answer.CheckAnswer ("20 i 10"));
            Assert.AreEqual (true, answer.CheckAnswer ("20 y 10"));
            Assert.AreEqual (true, answer.CheckAnswer ("20 10"));
            Assert.AreEqual (true, answer.CheckAnswer (" 20 10 "));

            // Invalid answers
            Assert.AreEqual (false, answer.CheckAnswer (" 10 30 "));
            Assert.AreEqual (false, answer.CheckAnswer ("10"));
            Assert.AreEqual (false, answer.CheckAnswer ("20"));
            Assert.AreEqual (false, answer.CheckAnswer ("10 2"));
        }
Esempio n. 9
0
        public void MatchAllCheatNumbers()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
            answer.CheckExpression = "[0-9]+";
            answer.Correct = "10 | 20 | 30";
            Assert.AreEqual (false, answer.CheckAnswer ("10 20 30 40 50"));
        }
Esempio n. 10
0
        public void MatchAllInOder()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes = GameAnswerCheckAttributes.MatchAllInOrder;
            answer.CheckExpression = "[0-9]+";
            answer.Correct = "10 | 20 | 30";

            Assert.AreEqual (true, answer.CheckAnswer ("10 20 30"));
            Assert.AreEqual (false, answer.CheckAnswer ("30 20 10"));
            Assert.AreEqual (false, answer.CheckAnswer ("i"));
        }
Esempio n. 11
0
        public void MatchAllCheatMultiOption()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll | GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
            answer.CheckExpression = "[ABCDEFGH]";
            answer.Correct = "A | B | C";
            Assert.AreEqual (false, answer.CheckAnswer ("A B C D"));
        }
Esempio n. 12
0
        public void IgnoreSpaces()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes = GameAnswerCheckAttributes.None;
            answer.Correct = "10 pm";
            Assert.AreEqual (true, answer.CheckAnswer ("10 pm"));
            Assert.AreEqual (false, answer.CheckAnswer ("10pm"));

            answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreSpaces;
            Assert.AreEqual (true, answer.CheckAnswer ("10 pm"));
            Assert.AreEqual (true, answer.CheckAnswer ("10pm"));

            answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("10 pm"));
            Assert.AreEqual (false, answer.CheckAnswer ("10pm"));

            answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreSpaces | GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("10 pm"));
            Assert.AreEqual (true, answer.CheckAnswer ("10pm"));
        }
Esempio n. 13
0
        public void IgnoreCase()
        {
            GameAnswer answer = new GameAnswer ();

            answer.CheckAttributes = GameAnswerCheckAttributes.None;
            answer.Correct = "icon";
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (false, answer.CheckAnswer ("ICON"));

            answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (true, answer.CheckAnswer ("ICON"));

            answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (false, answer.CheckAnswer ("ICON"));

            answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.MatchAll;
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));
            Assert.AreEqual (true, answer.CheckAnswer ("ICON"));
        }
Esempio n. 14
0
        public void DefaultAnswerOptions()
        {
            GameAnswer answer = new GameAnswer ();

            answer.Correct = "option1 | option2";
            Assert.AreEqual (true, answer.CheckAnswer ("option1"));
            Assert.AreEqual (true, answer.CheckAnswer ("option2"));
            Assert.AreEqual (true, answer.CheckAnswer (" option2 "));

            Assert.AreEqual (false, answer.CheckAnswer ("option3"));
        }
Esempio n. 15
0
        public void DefaultAnswer()
        {
            GameAnswer answer = new GameAnswer ();

            answer.Correct = "icon";
            Assert.AreEqual (true, answer.CheckAnswer ("icon"));

            answer.Correct = "icona";
            Assert.AreEqual (true, answer.CheckAnswer ("icona"));
        }