Search in sources :

Example 1 with BlankModel

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));
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) Model(com.orm.androrm.Model) BlankModel(com.orm.androrm.impl.BlankModel)

Example 2 with BlankModel

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());
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) BlankModelNoAutoincrement(com.orm.androrm.impl.BlankModelNoAutoincrement) Model(com.orm.androrm.Model) BlankModel(com.orm.androrm.impl.BlankModel)

Example 3 with BlankModel

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());
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) DatabaseAdapter(com.orm.androrm.DatabaseAdapter)

Example 4 with BlankModel

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());
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) Location(android.location.Location)

Example 5 with BlankModel

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));
}
Also used : BlankModel(com.orm.androrm.impl.BlankModel) BlankModelNoAutoincrement(com.orm.androrm.impl.BlankModelNoAutoincrement)

Aggregations

BlankModel (com.orm.androrm.impl.BlankModel)8 DatabaseAdapter (com.orm.androrm.DatabaseAdapter)2 Model (com.orm.androrm.Model)2 BlankModelNoAutoincrement (com.orm.androrm.impl.BlankModelNoAutoincrement)2 Location (android.location.Location)1 Date (java.util.Date)1