Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyPresenter(val api: Api, val view: MyView) {
- fun onSubmitClick() {
- api.submit().subscribe(
- onNext = { data -> view.showSuccess(data) },
- onError = { throwable -> view.showErrorDialog(throwable) }
- )
- }
- }
- fun testMyPresenterOnSubmitFail() {
- val view: MyView = mock()
- val mockApi: Api = mock {
- // จัดฉาก
- on(it.submit()).thenReturn(Observable.error(Throwable()))
- }
- val presenter = MyPresenter(mockApi, view)
- presenter.onSubmitClick()
- // วัดผล
- verify(view).showErrorDialog(any())
- }
Add Comment
Please, Sign In to add comment