Example #1
0
 protected void setUp() throws Exception {
   super.setUp();
   answerSource = AnswerDataSource.getInstance(getContext());
   answerSource.open();
   questionSource = QuestionDataSource.getInstance(getContext());
   questionSource.open();
 }
Example #2
0
 public void testGetAnswersToQuestion() throws wrongTypeException {
   int id = 8414075;
   ArrayList<Answer> answer = answerSource.getAnswers(id);
   int numberOfAnswers = questionSource.getNumberOfAnswers(id);
   Log.v("numberOfAnswers", Integer.toString(numberOfAnswers));
   Assert.assertEquals(answer.size(), numberOfAnswers);
 }
Example #3
0
 public void testAnswerType() {
   try {
     Answer answer = answerSource.getAnswer(386341);
     Assert.assertTrue(answer.getPostTypeId() == 2);
   } catch (Exception e) {
     Assert.assertTrue(true);
   }
 }
Example #4
0
 public void testAnswerInRT() {
   Question question = new Question("DummyTitle", "DummyBody", "DummyTag");
   int questionId = questionSource.setQuestion(question);
   Answer answer = new Answer(questionId, "DummyAnswer");
   int answerId = answerSource.setAnswer(answer);
   boolean Match = false;
   answerSource.addAnswerToRT(questionId, answerId);
   try {
     ArrayList<Answer> AnswerList = answerSource.getAnswers(questionId);
     for (Answer answ : AnswerList) {
       if (answ.getId() == answerId) Match = true;
     }
   } catch (Exception e) {
     Assert.assertTrue(true);
   }
   Assert.assertTrue(Match);
 }
Example #5
0
 public void testReadAnswer() {
   try {
     Answer answer =
         (Answer) answerSource.getAnswer(386350); // not sure that this id is in database
     Assert.assertEquals(answer.getId(), 386350);
   } catch (Exception e) {
     Assert.assertTrue(true);
   }
 }
Example #6
0
 public void testAnswerCountIncremented() {
   Question question = new Question("DummyTitle", "DummyBody", "DummyTag");
   questionSource.setQuestion(question);
   Answer answer = new Answer(question.getId(), "Write something");
   answerSource.setAnswer(answer);
   try {
     Question question2 = questionSource.getQuestion(question.getId());
     Assert.assertEquals((question.getAnswerCount() + 1), question2.getAnswerCount());
   } catch (Exception e) {
     Assert.assertTrue(true);
   }
 }
Example #7
0
 protected void tearDown() throws Exception {
   answerSource.close();
   questionSource.close();
   super.tearDown();
 }
Example #8
0
 public void testWritePostIsAddedToDatabase() {
   Answer answer = new Answer(386341, "Write something");
   answerSource.write(answer);
   Assert.assertEquals(answer.getBody(), answerSource.getLast().getBody());
 }