Ejemplo n.º 1
0
  public void testNullToNonNullResults() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), null, automaticUpdate);
    realmAdapter.updateRealmResults(resultList);

    assertEquals(TEST_DATA_SIZE, realmAdapter.getCount());
  }
Ejemplo n.º 2
0
 public void testEmptyRealmResult() {
   RealmResults<AllTypes> resultList =
       testRealm.where(AllTypes.class).equalTo(FIELD_STRING, "Not there").findAll();
   RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);
   assertEquals(0, realmAdapter.getRealmResults().size());
   assertEquals(0, realmAdapter.getCount());
 }
Ejemplo n.º 3
0
  public void testClearFromAdapter() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);

    testRealm.beginTransaction();
    realmAdapter.getRealmResults().clear();
    testRealm.commitTransaction();

    assertEquals(0, realmAdapter.getCount());
    assertEquals(0, resultList.size());
  }
Ejemplo n.º 4
0
  public void testRemoveFromAdapter() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);

    testRealm.beginTransaction();
    realmAdapter.getRealmResults().remove(0);
    testRealm.commitTransaction();
    assertEquals(TEST_DATA_SIZE - 1, realmAdapter.getCount());

    resultList = testRealm.where(AllTypes.class).equalTo(FIELD_STRING, "test data 0").findAll();
    assertEquals(0, resultList.size());
  }
Ejemplo n.º 5
0
  public void testNullResults() {
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), null, automaticUpdate);

    assertEquals(0, realmAdapter.getCount());
  }