Esempio n. 1
0
  @Test
  public void testDatabaseStructureViaSimpleInsertion() {
    testDatabaseStructureForSuccessfulBookEntryInsertion();
    assertThat(this.sqLiteDatabase.isOpen(), is(true));

    // Testing lending entry insertion
    ContentValues testLendingValues = TestDataHelper.createLendingEntry(this.testBookId);
    long lendingId = this.sqLiteDatabase.insert(LendingEntry.TABLE_NAME, null, testLendingValues);
    assertThat(lendingId, is(not(-1L))); // Check if the row was really inserted
    Log.d(LOG_TAG, "New lending id: " + lendingId);

    Cursor cursor =
        this.sqLiteDatabase.query(LendingEntry.TABLE_NAME, null, null, null, null, null, null);
    ValidationHelper.validateCursor(cursor, testLendingValues);
    cursor.close();
  }
Esempio n. 2
0
  @Test
  public void testDatabaseStructureForSuccessfulBookEntryInsertion() {
    assertThat(this.sqLiteDatabase.isOpen(), is(true));

    // testing book entry insertion
    ContentValues testBookValues = TestDataHelper.createAndroidRecipesValues();
    this.testBookId = this.sqLiteDatabase.insert(BookEntry.TABLE_NAME, null, testBookValues);
    assertThat(this.testBookId, is(not(-1L))); // Check if the row was really inserted
    Log.d(LOG_TAG, "New book id: " + this.testBookId);

    // Testing book insertion
    Cursor cursor =
        this.sqLiteDatabase.query(BookEntry.TABLE_NAME, null, null, null, null, null, null);
    ValidationHelper.validateCursor(cursor, testBookValues);
    cursor.close();
  }