Created
March 12, 2020 19:15
-
-
Save FilipeLipan/c693be1a7bc7aa56d18e172cf306e89c to your computer and use it in GitHub Desktop.
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
package com.ebanx.go.app.feature_signup | |
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | |
import com.ebanx.go.app.shared_kotlin.functional.Either | |
import com.ebanx.go.domain.interactor.GetSupportedCountriesUseCase | |
import com.ebanx.go.domain.model.Country | |
import com.nhaarman.mockitokotlin2.any | |
import com.nhaarman.mockitokotlin2.given | |
import junit.framework.Assert.assertEquals | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.newSingleThreadContext | |
import kotlinx.coroutines.runBlocking | |
import kotlinx.coroutines.test.resetMain | |
import kotlinx.coroutines.test.runBlockingTest | |
import kotlinx.coroutines.test.setMain | |
import org.junit.After | |
import org.junit.Before | |
import org.junit.Test | |
import org.junit.Rule | |
import org.junit.runner.RunWith | |
import org.mockito.Mock | |
import org.mockito.junit.MockitoJUnitRunner | |
/** | |
* Example local unit test, which will execute on the development machine (host). | |
* | |
* See [testing documentation](http://d.android.com/tools/testing). | |
*/ | |
@RunWith(MockitoJUnitRunner.Silent::class) | |
class ExampleUnitTest { | |
@get:Rule | |
var instantExecutorRule = InstantTaskExecutorRule() | |
@Mock | |
private lateinit var getSupportedCountriesUseCase: GetSupportedCountriesUseCase | |
lateinit var newUkSignInViewModel: NewUkSignInViewModel | |
@Test | |
fun asdas() { | |
given { runBlocking { getSupportedCountriesUseCase.run(any()) } } | |
.willReturn(Either.Right(listOf(Country("BR")))) | |
newUkSignInViewModel = NewUkSignInViewModel(getSupportedCountriesUseCase) | |
runBlocking { newUkSignInViewModel.loadCountries() } | |
assertEquals(newUkSignInViewModel.countriesAvailableNames.value, "BRL") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment