From c917dc13dabe7781a097383ae89f2d00f32fffcb Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 5 Mar 2019 18:31:47 -0500 Subject: Create initial room models --- .../com/pitchedapps/frost/db/FrostDatabaseTest.kt | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt (limited to 'app/src/androidTest/kotlin') diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt new file mode 100644 index 00000000..6b68e804 --- /dev/null +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt @@ -0,0 +1,46 @@ +package com.pitchedapps.frost.db + +import android.content.Context +import androidx.room.Room +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import kotlinx.coroutines.runBlocking +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import kotlin.test.assertEquals + +@RunWith(AndroidJUnit4::class) +class FrostDatabaseTest { + + private lateinit var db: FrostDatabase + + @Before + fun before() { + + val context = ApplicationProvider.getApplicationContext() + val privateDb = Room.inMemoryDatabaseBuilder( + context, FrostPrivateDatabase::class.java + ).build() + val publicDb = Room.inMemoryDatabaseBuilder( + context, FrostPublicDatabase::class.java + ).build() + db = FrostDatabase(privateDb, publicDb) + } + + @After + fun after() { + db.close() + } + + @Test + fun basic() { + val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie") + runBlocking { + db.cookieDao().insertCookie(cookie) + val cookies = db.cookieDao().selectAll() + assertEquals(listOf(cookie), cookies, "Cookie mismatch") + } + } +} \ No newline at end of file -- cgit v1.2.3