I am creating tests for an SQLite data base with a blob data type. I would like to validate blob (byte array - picture).
This is what i have and right now I am not checking PICTURES_COLUMN which causes an error (blob cant be parsed to String).
Comparing Set made from ContentValues to a cursor:
public void testHotelSingleInsert() {
SQLiteDatabase testDb = testDbHelper.getWritableDatabase();
long testRowId;
ContentValues testContentValues = TestUtils.getSingleContentValue(testContext);
testRowId = testDb.insert(HotelsEntry.TABLE_NAME, null, testContentValues);
assertTrue("Error: single insert to hotel table failed", testRowId != -1L);
Set<Map.Entry<String, Object>> testSet = testContentValues.valueSet();
Cursor cursor = testDb.query(HotelsEntry.TABLE_NAME, null, null, null, null, null, null);
cursor.moveToFirst();
for (Map.Entry<String, Object> entry : testSet) {
String columnName = entry.getKey();
int columnId = cursor.getColumnIndex(columnName);
if (entry.getKey().toString() != HotelsEntry.PICTURES_COLUMN) {
assertEquals(
"Value: " + entry.getValue().toString() + " is not equal to: " + cursor.getString(columnId),
entry.getValue().toString(),
cursor.getString(columnId));
}
}
}
How can I validate that blob in a professional way? Do I have treat blob separetly and get it out of the cursor?
Aucun commentaire:
Enregistrer un commentaire