Created
April 9, 2018 05:18
-
-
Save vincent-paing/b6f1f95e426ec7af41da084016b20715 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
internal fun stubNews(single: Single<List<NewsModel>> = Single.just(mock())) { | |
whenever(TestApplication.getMockedDataManager().getNews(any())).thenReturn(single) | |
} |
This file contains hidden or 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
val testAppModule = applicationContext { | |
bean<ThreadExecutor> { | |
JobExecutor() | |
} | |
bean<PostExecutionThread> { | |
UiThread() | |
} | |
bean<NetworkManager> { | |
mock() | |
} | |
bean<PersistenceManager> { | |
mock() | |
} | |
bean<DataManager> { | |
mock() | |
} | |
bean<ErrorMessageFactory> { | |
ErrorMessageFactoryImpl(get()) | |
} | |
bean<DeviceIdManager> { | |
DeviceIdAndroidManager(get()) | |
} | |
} |
This file contains hidden or 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
class TestApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
startKoin(this, listOf(testAppModule) | |
} | |
companion object { | |
fun getMockedDataManager() : DataManager { | |
return (StandAloneContext.koinContext as KoinContext).get { emptyMap() } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment