2 * Copyright (C) 2012 Martin Kempf <mkempf@hsr.ch>
3 * Copyright (C) 2012 Reto Buerki <reet@codelabs.ch>
4 * Copyright (C) 2012 Adrian-Ken Rueegsegger <ken@codelabs.ch>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 package ch.codelabs.gitter.test;
19 import android.database.Cursor;
20 import android.test.AndroidTestCase;
22 import ch.codelabs.gitter.CommitDbAdapter;
24 public class CommitDbAdapterTest extends AndroidTestCase {
29 public CommitDbAdapterTest() {
34 * Insert commit into database.
36 public void testInsertCommit() {
37 final CommitDbAdapter commitDbAdapter = new
38 CommitDbAdapter(getContext());
39 commitDbAdapter.open();
41 final long id = commitDbAdapter.insertCommit("Update TODO",
42 "John Doe doe@example.com", "http://1.com/abc", "testdata");
44 final Cursor c = commitDbAdapter.fetchAllCommits();
45 assertTrue(c.getCount() > 0);
48 assertEquals(0, c.getInt
49 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_READ)));
50 assertEquals("Update TODO", c.getString
51 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_TITLE)));
52 assertEquals("John Doe doe@example.com", c.getString
53 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_AUTHOR)));
54 assertEquals("http://1.com/abc", c.getString
55 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_DIFFLINK)));
56 assertEquals("testdata", c.getString
57 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_CONTENT)));
59 commitDbAdapter.deleteCommit(id);
61 commitDbAdapter.close();