use of com.orm.model.SimpleModel in project sugar by satyan.
the class CursorTests method testColumnNames.
@Test
public void testColumnNames() {
save(new SimpleModel());
Cursor c = Select.from(SimpleModel.class).getCursor();
for (String col : new String[] { "STR", "INTEGER", "BOOL", "ID" }) {
assertNotSame("Missing column for field: " + col, -1, c.getColumnIndex(col));
}
}
use of com.orm.model.SimpleModel in project sugar by satyan.
the class CursorTests method testMakeAdapter.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testMakeAdapter() {
save(new SimpleModel());
Cursor c = Select.from(SimpleModel.class).getCursor();
CursorAdapter adapter = new CursorAdapter(RuntimeEnvironment.application, c, true) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
TextView tv = new TextView(context);
String s = cursor.getString(cursor.getColumnIndex("STR"));
tv.setText(s);
return null;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
String s = cursor.getString(cursor.getColumnIndex("STR"));
((TextView) view).setText(s);
}
};
Assert.assertNotNull(adapter);
}
use of com.orm.model.SimpleModel in project sugar by satyan.
the class CursorTests method testNoColumn.
@Test
public void testNoColumn() {
save(new SimpleModel());
Cursor cursor = Select.from(SimpleModel.class).getCursor();
assertSame(-1, cursor.getColumnIndex("nonexistent"));
}
use of com.orm.model.SimpleModel in project sugar by satyan.
the class CursorTests method testSugarCursor.
@Test
public void testSugarCursor() {
save(new SimpleModel());
Cursor cursor = Select.from(SimpleModel.class).getCursor();
assertNotSame("No _id", -1, cursor.getColumnIndex("_id"));
assertSame("_id != ID", cursor.getColumnIndex("_id"), cursor.getColumnIndex("ID"));
}
Aggregations