use of android.test.mock.MockCursor in project devbricks by dailystudio.
the class DatabaseObjectFactoryTest method testCreateDatabaseObject.
public void testCreateDatabaseObject() {
Template templ = new Template();
assertNotNull(templ);
templ.addColumn(TestDatabaseObject.COLUMN_INTEGER_VAL);
templ.addColumn(TestDatabaseObject.COLUMN_LONG_VAL);
templ.addColumn(TestDatabaseObject.COLUMN_DOUBLE_VAL);
templ.addColumn(TestDatabaseObject.COLUMN_TEXT_VAL);
templ.addColumn(TestDatabaseObject.COLUMN_BLOB_VAL);
DatabaseObject object = null;
object = DatabaseObjectFactory.createDatabaseObject(TestDatabaseObject.class);
assertNotNull(object);
assertEquals(true, object instanceof TestDatabaseObject);
assertEquals(templ, object.getTemplate());
MockCursor cursor = new SimpleMockCursor();
assertNotNull(cursor);
assertEquals(true, cursor.moveToFirst());
int i = 0;
do {
object = DatabaseObjectFactory.createDatabaseObject(TestDatabaseObject.class);
assertNotNull(object);
object.fillValuesFromCursor(cursor);
assertEquals(true, object instanceof TestDatabaseObject);
assertEquals(templ, object.getTemplate());
assertEquals(i, object.getIntegerValue(TestDatabaseObject.COLUMN_INTEGER_VAL));
assertEquals(i * 1000l, object.getLongValue(TestDatabaseObject.COLUMN_LONG_VAL));
assertEquals(i * 0.0001, object.getDoubleValue(TestDatabaseObject.COLUMN_DOUBLE_VAL));
assertEquals(String.format("Text%03d", i), object.getTextValue(TestDatabaseObject.COLUMN_TEXT_VAL));
i++;
} while (cursor.moveToNext());
}
Aggregations