// Many people would suggest that this test is bad since it test two different things // Test space before answer and space after answer public void checkAnswer_ExtrasSpaceTest() { // Arrange String strQuestion = "Test question here?"; String strAnswer = "Answer to question"; String strAnswerWithSpaceAfter = "Answer to question "; String strAnswerWithSpaceBefore = " Answer to question"; Question q = new ShortAnswerQuestion(strQuestion, strAnswer); //Act //Assert Assert.IsTrue(q.checkAnswer(strAnswerWithSpaceAfter)); Assert.IsTrue(q.checkAnswer(strAnswerWithSpaceBefore)); }
public void checkAnswer_NormalTest() { // Arrange String strQuestion = "Test 301"; String strAnswer = "Answer 301"; Question q = new ShortAnswerQuestion(strQuestion, strAnswer); //Act //Assert Assert.IsTrue(q.checkAnswer(strAnswer)); }
public void checkAnswer_LowerCaseTest() { // Arrange String strQuestion = "Test 302"; String strAnswer = "Answer 302"; String strLowerCaseAnswer = "answer 302"; Question q = new ShortAnswerQuestion(strQuestion, strAnswer); //Act //Assert Assert.IsTrue(q.checkAnswer(strLowerCaseAnswer)); }
public void checkAnswer_WrongAnswerTest() { // Arrange String strQuestion = "Test 304"; String strAnswer = "Given Answer 304"; String strWrongAnswer = "Wrong Answer 304"; Question q = new ShortAnswerQuestion(strQuestion, strAnswer); //Act String strResult = q.getAnswer(); //Assert Assert.IsFalse(q.checkAnswer(strWrongAnswer)); }