aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-03-06 17:42:31 -0500
committerAllan Wang <me@allanwang.ca>2019-03-06 17:42:31 -0500
commit8b70d80070209eb19791eecf207a8fdefea17a4e (patch)
tree41ed8afcbe74d138fc6dbf601c5e6e33486e8969 /app/src/androidTest
parent9a1d9719ad6559054ea1bc4f21f8559559eb9cda (diff)
downloadfrost-8b70d80070209eb19791eecf207a8fdefea17a4e.tar.gz
frost-8b70d80070209eb19791eecf207a8fdefea17a4e.tar.bz2
frost-8b70d80070209eb19791eecf207a8fdefea17a4e.zip
Make db entities immutable
Diffstat (limited to 'app/src/androidTest')
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieDbTest.kt34
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt12
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt20
3 files changed, 45 insertions, 21 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieDbTest.kt
index 351490e2..20592347 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieDbTest.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/CookieDbTest.kt
@@ -6,13 +6,15 @@ import kotlin.test.assertEquals
import kotlin.test.assertNull
class CookieDbTest : BaseDbTest() {
+
+ private val dao get() = db.cookieDao()
@Test
fun basicCookie() {
val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
runBlocking {
- db.cookieDao().insertCookie(cookie)
- val cookies = db.cookieDao().selectAll()
+ dao.insertCookie(cookie)
+ val cookies = dao.selectAll()
assertEquals(listOf(cookie), cookies, "Cookie mismatch")
}
}
@@ -22,15 +24,15 @@ class CookieDbTest : BaseDbTest() {
val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
runBlocking {
- db.cookieDao().insertCookie(cookie)
- db.cookieDao().deleteById(cookie.id + 1)
+ dao.insertCookie(cookie)
+ dao.deleteById(cookie.id + 1)
assertEquals(
listOf(cookie),
- db.cookieDao().selectAll(),
+ dao.selectAll(),
"Cookie list should be the same after inexistent deletion"
)
- db.cookieDao().deleteById(cookie.id)
- assertEquals(emptyList(), db.cookieDao().selectAll(), "Cookie list should be empty after deletion")
+ dao.deleteById(cookie.id)
+ assertEquals(emptyList(), dao.selectAll(), "Cookie list should be empty after deletion")
}
}
@@ -38,18 +40,18 @@ class CookieDbTest : BaseDbTest() {
fun insertReplaceCookie() {
val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
runBlocking {
- db.cookieDao().insertCookie(cookie)
- assertEquals(listOf(cookie), db.cookieDao().selectAll(), "Cookie insertion failed")
- db.cookieDao().insertCookie(cookie.copy(name = "testName2"))
+ dao.insertCookie(cookie)
+ assertEquals(listOf(cookie), dao.selectAll(), "Cookie insertion failed")
+ dao.insertCookie(cookie.copy(name = "testName2"))
assertEquals(
listOf(cookie.copy(name = "testName2")),
- db.cookieDao().selectAll(),
+ dao.selectAll(),
"Cookie replacement failed"
)
- db.cookieDao().insertCookie(cookie.copy(id = 123L))
+ dao.insertCookie(cookie.copy(id = 123L))
assertEquals(
setOf(cookie.copy(id = 123L), cookie.copy(name = "testName2")),
- db.cookieDao().selectAll().toSet(),
+ dao.selectAll().toSet(),
"New cookie insertion failed"
)
}
@@ -59,9 +61,9 @@ class CookieDbTest : BaseDbTest() {
fun selectCookie() {
val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
runBlocking {
- db.cookieDao().insertCookie(cookie)
- assertEquals(cookie, db.cookieDao().selectById(cookie.id), "Cookie selection failed")
- assertNull(db.cookieDao().selectById(cookie.id + 1), "Inexistent cookie selection failed")
+ dao.insertCookie(cookie)
+ assertEquals(cookie, dao.selectById(cookie.id), "Cookie selection failed")
+ assertNull(dao.selectById(cookie.id + 1), "Inexistent cookie selection failed")
}
}
} \ No newline at end of file
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt
index a2dce692..91a0bf9a 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FbTabsDbTest.kt
@@ -7,6 +7,8 @@ import kotlin.test.Test
import kotlin.test.assertEquals
class FbTabsDbTest : BaseDbTest() {
+
+ private val dao get() = db.tabDao()
/**
* Note that order is also preserved here
@@ -15,18 +17,18 @@ class FbTabsDbTest : BaseDbTest() {
fun save() {
val tabs = listOf(FbItem.ACTIVITY_LOG, FbItem.BIRTHDAYS, FbItem.EVENTS, FbItem.MARKETPLACE, FbItem.ACTIVITY_LOG)
runBlocking {
- db.tabDao().save(tabs)
- assertEquals(tabs, db.tabDao().selectAll(), "Tab saving failed")
+ dao.save(tabs)
+ assertEquals(tabs, dao.selectAll(), "Tab saving failed")
val newTabs = listOf(FbItem.PAGES, FbItem.MENU)
- db.tabDao().save(newTabs)
- assertEquals(newTabs, db.tabDao().selectAll(), "Tab saving does not delete preexisting items")
+ dao.save(newTabs)
+ assertEquals(newTabs, dao.selectAll(), "Tab saving does not delete preexisting items")
}
}
@Test
fun defaultRetrieve() {
runBlocking {
- assertEquals(defaultTabs(), db.tabDao().selectAll(), "Default retrieval failed")
+ assertEquals(defaultTabs(), dao.selectAll(), "Default retrieval failed")
}
}
} \ No newline at end of file
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt
new file mode 100644
index 00000000..12092bf6
--- /dev/null
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/NotificationDbTest.kt
@@ -0,0 +1,20 @@
+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 NotificationDbTest : BaseDbTest() {
+
+ private val dao get() = db.notifDao()
+
+ /**
+ * Note that order is also preserved here
+ */
+ @Test
+ fun save() {
+
+ }
+} \ No newline at end of file