Ejemplo n.º 1
0
 @Test
 public void canAddQuestion() {
   questionManager.addQuestion(question);
   questionDatabase.switchMode(QuestionMode.CUSTOM_ONLY);
   int number = questionDatabase.getNumberOfQuestions(question.getLevel());
   Question loadedQuestion =
       questionDatabase.getQuestion(question.getLevel(), question.getCategory(), number - 1);
   assertEquals(oldNumberOfQuestions + 1, number);
   assertEquals("Questions do not match", question, loadedQuestion);
 }
Ejemplo n.º 2
0
 @After
 public void cleanup() {
   questionDatabase = QuestionDatabaseFactory.aQuestionDatabaseWithOnlyCustomQuestions();
   int numberToDelete =
       questionDatabase.getNumberOfQuestions(question.getLevel()) - oldNumberOfQuestions;
   for (int ii = 0; ii < numberToDelete; ii++) {
     Question questionToDelete =
         questionDatabase.getQuestion(
             question.getLevel(), question.getCategory(), oldNumberOfQuestions + ii);
     questionManager.deleteQuestion(questionToDelete);
   }
 }
Ejemplo n.º 3
0
  /*
      @Test
      public void canDeleteQuestion() {
          canAddQuestion();
          questionManager.deleteQuestion(question);
          questionDatabase = QuestionDatabaseFactory.aQuestionDatabaseWithOnlyCustomQuestions();
          int number = questionDatabase.getNumberOfQuestions(question.getLevel());
          assertEquals(oldNumberOfQuestions, number);
      }
  */
  @Test
  public void canEditQuestion() {
    final String newQuestionString = "HELLO THIS IS ME";

    questionManager.addQuestion(question);
    questionDatabase = QuestionDatabaseFactory.aQuestionDatabaseWithOnlyCustomQuestions();
    Question newQuestion = QuestionBuilder.aQuestion().copiedFrom(question).build();
    newQuestion.setQuestion(newQuestionString);
    questionManager.editQuestion(question, newQuestion);
    questionDatabase = QuestionDatabaseFactory.aQuestionDatabaseWithOnlyCustomQuestions();

    int number = questionDatabase.getNumberOfQuestions(question.getLevel()) - 1;
    Question loadedQuestion =
        questionDatabase.getQuestion(question.getLevel(), question.getCategory(), number);

    assertEquals("Question not edited", newQuestion, loadedQuestion);
  }