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 ("- +")); }
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")); }
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")); }
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")); }
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 ")); }
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")); }
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")); }
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")); }
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")); }
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")); }
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")); }
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")); }
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")); }