File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
app/src/test/kotlin/com/fernandocejas/sample/framework/platform Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.fernandocejas.sample.framework.platform
2+
3+ import android.arch.lifecycle.MutableLiveData
4+ import com.fernandocejas.sample.AndroidTest
5+ import com.fernandocejas.sample.framework.exception.Failure
6+ import com.fernandocejas.sample.framework.exception.Failure.NetworkConnection
7+ import org.amshove.kluent.shouldBeInstanceOf
8+ import org.junit.Test
9+
10+ class BaseViewModelTest : AndroidTest () {
11+
12+ @Test fun `should handle failure by updating live data` () {
13+ val viewModel = MyViewModel ()
14+
15+ viewModel.handleError(NetworkConnection ())
16+
17+ val failure = viewModel.failure
18+ val error = viewModel.failure.value
19+
20+ failure shouldBeInstanceOf MutableLiveData ::class .java
21+ error shouldBeInstanceOf NetworkConnection ::class .java
22+ }
23+
24+ private class MyViewModel : BaseViewModel () {
25+ fun handleError (failure : Failure ) = handleFailure(failure)
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments