diff options
author | Allan Wang <me@allanwang.ca> | 2019-03-07 19:36:09 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-03-07 19:36:09 -0500 |
commit | 3f5d2cf2a55d28528c88e118f09a91fd6c59ac43 (patch) | |
tree | 74d0e876c5689f11d9134d5ebd25b03860b1aeb0 /app/src/androidTest/kotlin/com/pitchedapps | |
parent | cac563f6c6a2656c74527bfa2c8b5780765baf69 (diff) | |
download | frost-3f5d2cf2a55d28528c88e118f09a91fd6c59ac43.tar.gz frost-3f5d2cf2a55d28528c88e118f09a91fd6c59ac43.tar.bz2 frost-3f5d2cf2a55d28528c88e118f09a91fd6c59ac43.zip |
Replace tab dao with generic dao
Diffstat (limited to 'app/src/androidTest/kotlin/com/pitchedapps')
-rw-r--r-- | app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt | 34 | ||||
-rw-r--r-- | app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt | 46 |
2 files changed, 46 insertions, 34 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt deleted file mode 100644 index 752112f9..00000000 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.pitchedapps.frost.db - -import com.pitchedapps.frost.facebook.FbItem -import com.pitchedapps.frost.facebook.defaultTabs -import kotlinx.coroutines.runBlocking -import kotlin.test.Test -import kotlin.test.assertEquals - -class FbTabsDbTest : BaseDbTest() { - - private val dao get() = db.tabDao() - - /** - * Note that order is also preserved here - */ - @Test - fun save() { - val tabs = listOf(FbItem.ACTIVITY_LOG, FbItem.BIRTHDAYS, FbItem.EVENTS, FbItem.MARKETPLACE, FbItem.ACTIVITY_LOG) - runBlocking { - dao.save(tabs) - assertEquals(tabs, dao.selectAll(), "Tab saving failed") - val newTabs = listOf(FbItem.PAGES, FbItem.MENU) - dao.save(newTabs) - assertEquals(newTabs, dao.selectAll(), "Tab saving does not delete preexisting items") - } - } - - @Test - fun defaultRetrieve() { - runBlocking { - assertEquals(defaultTabs(), dao.selectAll(), "Default retrieval failed") - } - } -}
\ No newline at end of file diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt new file mode 100644 index 00000000..9979eca4 --- /dev/null +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/GenericDbTest.kt @@ -0,0 +1,46 @@ +package com.pitchedapps.frost.db + +import com.pitchedapps.frost.facebook.FbItem +import com.pitchedapps.frost.facebook.defaultTabs +import kotlinx.coroutines.runBlocking +import kotlin.test.Test +import kotlin.test.assertEquals + +class GenericDbTest : BaseDbTest() { + + private val dao get() = db.genericDao() + + /** + * Note that order is also preserved here + */ + @Test + fun save() { + val tabs = listOf(FbItem.ACTIVITY_LOG, FbItem.BIRTHDAYS, FbItem.EVENTS, FbItem.MARKETPLACE, FbItem.ACTIVITY_LOG) + runBlocking { + dao.saveTabs(tabs) + assertEquals(tabs, dao.getTabs(), "Tab saving failed") + val newTabs = listOf(FbItem.PAGES, FbItem.MENU) + dao.saveTabs(newTabs) + assertEquals(newTabs, dao.getTabs(), "Tab overwrite failed") + } + } + + @Test + fun defaultRetrieve() { + runBlocking { + assertEquals(defaultTabs(), dao.getTabs(), "Default retrieval failed") + } + } + + @Test + fun ignoreErrors() { + runBlocking { + dao.save(GenericEntity(GenericDao.TYPE_TABS, "${FbItem.ACTIVITY_LOG.name},unknown,${FbItem.EVENTS.name}")) + assertEquals( + listOf(FbItem.ACTIVITY_LOG, FbItem.EVENTS), + dao.getTabs(), + "Tab fetching does not ignore unknown names" + ) + } + } +}
\ No newline at end of file |