Skip to content

Instantly share code, notes, and snippets.

@vincent-paing
Created April 9, 2018 05:18
Show Gist options
  • Save vincent-paing/b6f1f95e426ec7af41da084016b20715 to your computer and use it in GitHub Desktop.
Save vincent-paing/b6f1f95e426ec7af41da084016b20715 to your computer and use it in GitHub Desktop.
internal fun stubNews(single: Single<List<NewsModel>> = Single.just(mock())) {
whenever(TestApplication.getMockedDataManager().getNews(any())).thenReturn(single)
}
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())
}
}
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