From 55b2f827c0d02e25e4428ae86092d8f1212b1693 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 23 Jan 2013 13:08:36 -0800 Subject: [PATCH] Added unit test for recording outstanding entries when using DatabaseDao.update --- .../todoroo/astrid/sync/SyncModelTest.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests-sync/src/com/todoroo/astrid/sync/SyncModelTest.java b/tests-sync/src/com/todoroo/astrid/sync/SyncModelTest.java index 12025a5d1..40c52ec0b 100644 --- a/tests-sync/src/com/todoroo/astrid/sync/SyncModelTest.java +++ b/tests-sync/src/com/todoroo/astrid/sync/SyncModelTest.java @@ -1,7 +1,5 @@ package com.todoroo.astrid.sync; -import android.text.TextUtils; - import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Query; @@ -41,6 +39,31 @@ public class SyncModelTest extends NewSyncTestCase { } } + public void testUpdateMakesAllOutstandingEntries() { + String title = "Task Important"; + createTask(title, true); + createTask("Task Not Important", true); + createTask(title, true); + + Task template = new Task(); + template.setValue(Task.IMPORTANCE, Task.IMPORTANCE_DO_OR_DIE); + + taskDao.update(Task.TITLE.eq(title), template); + + TodorooCursor cursor = taskOutstandingDao.query(Query.select(TaskOutstanding.PROPERTIES)); + try { + assertEquals(2, cursor.getCount()); + TaskOutstanding to = new TaskOutstanding(); + for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { + to.readPropertiesFromCursor(cursor); + assertEquals(Task.IMPORTANCE.name, to.getValue(TaskOutstanding.COLUMN_STRING)); + assertEquals(Task.IMPORTANCE_DO_OR_DIE, Integer.parseInt(to.getValue(TaskOutstanding.VALUE_STRING))); + } + } finally { + cursor.close(); + } + } + public void testChangeTagMakesOutstandingEntries() { TagData tag = createTagData(); String newName = "changing tag name";