-
Notifications
You must be signed in to change notification settings - Fork 9
/
CovidTrackerDaoRobolectricTest.kt
37 lines (32 loc) · 1.21 KB
/
CovidTrackerDaoRobolectricTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.jaimegc.covid19tracker.room
import com.google.common.truth.Truth.assertThat
import com.jaimegc.covid19tracker.ModelFactoryTest.worldAndCountriesStatsPojo
import com.jaimegc.covid19tracker.util.DatabaseRobolectricTest
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class CovidTrackerDaoRobolectricTest : DatabaseRobolectricTest() {
@Before
fun setup() {
covidTrackerDao = database.covidTrackerDao()
}
@Test
fun getWorldAndCountriesStatsByLastDate_shouldReturnPojo() = runBlocking {
covidTrackerDao.getWorldAndCountriesStatsByLastDate().take(1).collect {
assertThat(it).isEqualTo(worldAndCountriesStatsPojo)
}
}
@Test
fun getWorldAndCountriesStatsByDate_shouldReturnPojo() = runBlocking {
covidTrackerDao.getWorldAndCountriesStatsByDate(
worldAndCountriesStatsPojo.worldStats!!.dateTimestamp
).take(1).collect {
assertThat(it).isEqualTo(worldAndCountriesStatsPojo)
}
}
}