コード例 #1
0
  @Test
  public void getCommentsTest() {
    mCommentService = CommentService.getInstance();
    Comment comment1 = new Comment();
    comment1.setId(9999991);
    comment1.setText("text");
    comment1.setBy("by");
    comment1.setTime(120000);

    Comment comment2 = new Comment();
    comment2.setId(9999992);
    comment2.setText("text");
    comment2.setBy("by");
    comment2.setTime(120000);

    long r1 = mCommentService.createComment(RuntimeEnvironment.application, comment1);
    Assert.assertTrue(r1 > 0);

    long r2 = mCommentService.createComment(RuntimeEnvironment.application, comment2);
    Assert.assertTrue(r2 > 0);

    // check items
    List<Comment> dbComments = mCommentService.getComments(RuntimeEnvironment.application);
    Assert.assertTrue(dbComments != null && dbComments.size() == 2);

    // remove item
    mCommentService.removeComment(RuntimeEnvironment.application, 9999991);
    mCommentService.removeComment(RuntimeEnvironment.application, 9999992);

    // Close connection
    SQLiteDataBaseHelper.getInstance(RuntimeEnvironment.application).getWritableDatabase().close();
  }
コード例 #2
0
  @Test
  public void createCommentTest() {
    mCommentService = CommentService.getInstance();
    Comment comment = new Comment();
    comment.setId(999999);
    comment.setText("text");
    comment.setBy("by");
    comment.setTime(120000);

    long result = mCommentService.createComment(RuntimeEnvironment.application, comment);
    Assert.assertTrue(result > 0);

    // remove item
    long del = mCommentService.removeComment(RuntimeEnvironment.application, 999999);
    Assert.assertTrue(del > 0);

    // Close connection
    SQLiteDataBaseHelper.getInstance(RuntimeEnvironment.application).getWritableDatabase().close();
  }