Created
May 22, 2021 06:19
-
-
Save seoft/a791ffba460d47eb056d2d5501dad461 to your computer and use it in GitHub Desktop.
MyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.test.ext.junit.runners.AndroidJUnit4 | |
import androidx.test.platform.app.InstrumentationRegistry | |
import io.reactivex.internal.functions.Functions | |
import io.reactivex.rxkotlin.subscribeBy | |
import org.junit.Assert | |
import org.junit.Rule | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
import org.koin.test.KoinTest | |
import org.koin.test.inject | |
@RunWith(AndroidJUnit4::class) | |
class MyTest : KoinTest { | |
val settingRepository by inject<SettingRepository>() | |
val appContext by lazy { InstrumentationRegistry.getInstrumentation().targetContext } // not used here | |
@Rule | |
@JvmField | |
val rule = RxSchedulerRule() | |
@Test | |
fun testLatelySearchKeyword() { | |
settingRepository.clearLatelySearchKeyword().subscribe(Functions.EMPTY_ACTION) | |
settingRepository.getLatelySearchKeyword().subscribeBy(onSuccess = { | |
Assert.assertEquals(0, it.size) | |
}) | |
settingRepository.addLatelySearchKeyword("111").subscribe(Functions.EMPTY_ACTION) | |
settingRepository.addLatelySearchKeyword("222").subscribe(Functions.EMPTY_ACTION) | |
settingRepository.addLatelySearchKeyword("333").subscribe(Functions.EMPTY_ACTION) | |
settingRepository.addLatelySearchKeyword("444").subscribe(Functions.EMPTY_ACTION) | |
settingRepository.addLatelySearchKeyword("111").subscribe(Functions.EMPTY_ACTION) | |
settingRepository.getLatelySearchKeyword().subscribeBy(onSuccess = { | |
Assert.assertEquals(listOf("111", "444", "333", "222"), it) | |
}) | |
settingRepository.clearLatelySearchKeyword().subscribe(Functions.EMPTY_ACTION) | |
settingRepository.getLatelySearchKeyword().subscribeBy(onSuccess = { | |
Assert.assertEquals(0, it.size) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment