Пример #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());
  }
Пример #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());
 }
Пример #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());
  }
Пример #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());
  }
Пример #5
0
  public void testNullResults() {
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), null, automaticUpdate);

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