use of com.orm.androrm.impl.BlankModel in project androrm by androrm.
the class ModelTest method testSave.
public void testSave() {
Model m = new BlankModel();
assertTrue(m.save(getContext()));
assertEquals(1, m.getId());
assertFalse(m.save(getContext(), 5));
}
use of com.orm.androrm.impl.BlankModel in project androrm by androrm.
the class ModelTest method testInitialId.
public void testInitialId() {
Model m = new BlankModel();
assertEquals(0, m.getId());
m = new BlankModelNoAutoincrement();
assertEquals(0, m.getId());
}
use of com.orm.androrm.impl.BlankModel in project androrm by androrm.
the class TransactionTest method testRollback.
public void testRollback() {
assertEquals(0, BlankModel.objects(getContext()).count());
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.beginTransaction();
BlankModel b1 = new BlankModel();
b1.save(getContext());
BlankModel b2 = new BlankModel();
b2.save(getContext());
adapter.rollbackTransaction();
assertEquals(0, BlankModel.objects(getContext()).count());
}
use of com.orm.androrm.impl.BlankModel in project androrm by androrm.
the class LocationFieldTest method testSave.
public void testSave() {
Location l = new Location(LocationManager.GPS_PROVIDER);
l.setLatitude(1.0);
l.setLongitude(2.0);
BlankModel b = new BlankModel();
b.setLocation(l);
b.save(getContext());
BlankModel b2 = Model.objects(getContext(), BlankModel.class).get(b.getId());
Location l2 = b2.getLocation();
assertEquals(1.0, l2.getLatitude());
assertEquals(2.0, l2.getLongitude());
}
use of com.orm.androrm.impl.BlankModel in project androrm by androrm.
the class ModelTest method testEquals.
public void testEquals() {
BlankModel m = new BlankModel();
m.setName("test");
m.save(getContext());
BlankModel m2 = Model.objects(getContext(), BlankModel.class).get(m.getId());
assertEquals(m, m2);
BlankModelNoAutoincrement m3 = new BlankModelNoAutoincrement();
m3.save(getContext(), 1);
assertFalse(m.equals(m3));
}
Aggregations