예제 #1
0
 @Test
 public void getCount() {
   cursor.setResults(
       new Object[][] {
         new Object[] {"aString", 1234L, 41}, new Object[] {"anotherString", 5678L, 42}
       });
   assertThat(cursor.getCount()).isEqualTo(2);
 }
예제 #2
0
 @Test
 public void moveToPositionBoundsChecks() {
   cursor.setResults(
       new Object[][] {
         new Object[] {"aString", 1234L, 41}, new Object[] {"anotherString", 5678L, 42}
       });
   assertThat(cursor.moveToPosition(2)).isFalse();
   assertThat(cursor.moveToPosition(-1)).isFalse();
 }
예제 #3
0
 @Test
 public void canGetStringsAndLongs() throws Exception {
   cursor.setResults(new Object[][] {new Object[] {"aString", 1234L, 42}});
   assertThat(cursor.getCount()).isEqualTo(1);
   assertThat(cursor.getColumnCount()).isEqualTo(3);
   assertThat(cursor.getType(0)).isEqualTo(Cursor.FIELD_TYPE_STRING);
   assertThat(cursor.getColumnName(0)).isEqualTo("stringColumn");
   assertThat(cursor.getColumnName(1)).isEqualTo("longColumn");
   assertThat(cursor.getType(1)).isEqualTo(Cursor.FIELD_TYPE_INTEGER);
   assertThat(cursor.moveToNext()).isTrue();
   assertThat(cursor.getString(cursor.getColumnIndex("stringColumn"))).isEqualTo("aString");
   assertThat(cursor.getLong(cursor.getColumnIndex("longColumn"))).isEqualTo(1234L);
   assertThat(cursor.getInt(cursor.getColumnIndex("intColumn"))).isEqualTo(42);
 }
예제 #4
0
  @Test
  public void moveToPositionMovesToAppropriateRow() throws Exception {
    cursor.setResults(
        new Object[][] {
          new Object[] {"aString", 1234L, 41}, new Object[] {"anotherString", 5678L, 42}
        });
    assertThat(cursor.moveToPosition(1)).isTrue();
    assertThat(cursor.getString(cursor.getColumnIndex("stringColumn"))).isEqualTo("anotherString");
    assertThat(cursor.getLong(cursor.getColumnIndex("longColumn"))).isEqualTo(5678L);
    assertThat(cursor.getInt(cursor.getColumnIndex("intColumn"))).isEqualTo(42);

    assertThat(cursor.moveToPosition(0)).isTrue();
    assertThat(cursor.getString(cursor.getColumnIndex("stringColumn"))).isEqualTo("aString");
    assertThat(cursor.getLong(cursor.getColumnIndex("longColumn"))).isEqualTo(1234L);
    assertThat(cursor.getInt(cursor.getColumnIndex("intColumn"))).isEqualTo(41);
  }