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 CommitDbAdapter commitDbAdapter = new CommitDbAdapter(getContext());
38 commitDbAdapter.open();
40 long id = commitDbAdapter.insertCommit("Update TODO",
41 "John Doe doe@example.com", "http://1.com/abc", "testdata");
43 Cursor c = commitDbAdapter.fetchAllCommits();
44 assertTrue(c.getCount() > 0);
47 assertEquals("Update TODO", c.getString
48 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_TITLE)));
49 assertEquals("John Doe doe@example.com", c.getString
50 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_AUTHOR)));
51 assertEquals("http://1.com/abc", c.getString
52 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_DIFFLINK)));
53 assertEquals("testdata", c.getString
54 (c.getColumnIndexOrThrow(CommitDbAdapter.KEY_CONTENT)));
56 commitDbAdapter.deleteCommit(id);
58 commitDbAdapter.close();