Add task for importing/exporting

This commit is contained in:
Branden Archer
2016-05-12 22:54:18 -04:00
parent ce272fe7f1
commit 20338eb09b
3 changed files with 193 additions and 0 deletions

View File

@@ -204,4 +204,39 @@ public class ImportExportTest
assertEquals(0, db.getLoyaltyCardCount());
}
}
@Test
public void useImportExportTask()
{
final int NUM_CARDS = 10;
for(DataFormat format : DataFormat.values())
{
addLoyaltyCards(NUM_CARDS);
// Export to whatever the default location is
ImportExportTask task = new ImportExportTask(activity, false, format);
task.execute();
// Actually run the task to completion
Robolectric.flushBackgroundThreadScheduler();
clearDatabase();
// Import everything back from the default location
task = new ImportExportTask(activity, true, format);
task.execute();
// Actually run the task to completion
Robolectric.flushBackgroundThreadScheduler();
assertEquals(NUM_CARDS, db.getLoyaltyCardCount());
checkLoyaltyCards();
// Clear the database for the next format under test
clearDatabase();
}
}
}