예제 #1
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);
  }
예제 #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);
   }
 }
예제 #3
0
 @Before
 public void setup() {
   questionDatabase = QuestionDatabaseFactory.aQuestionDatabaseWithOnlyCustomQuestions();
   questionManager = QuestionDatabaseFactory.aQuestionManager();
   question =
       QuestionBuilder.aQuestion()
           .asking("What has four sides?")
           .ofType(QuestionType.TEXT)
           .withChoices("Square", "Circle", "Triangle", "Oval")
           .withAnswer("Square")
           .withExplaination("A square has four equal sides")
           .ofLevel(QuestionLevel.LEVEL_1)
           .inCategory(QuestionCategory.SHAPES)
           .build();
   oldNumberOfQuestions = questionDatabase.getNumberOfQuestions(question.getLevel());
 }