Skip to content

Instantly share code, notes, and snippets.

@fabioCollini
Created October 5, 2021 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioCollini/c79f9bce14c02d9b59d7bfeddcf8d6d7 to your computer and use it in GitHub Desktop.
Save fabioCollini/c79f9bce14c02d9b59d7bfeddcf8d6d7 to your computer and use it in GitHub Desktop.
class ViewModelTest {
@get:Rule
val mainCoroutineRule = MainCoroutineRule()
private val viewModel by lazy {
CalculatorViewModel(SavedStateHandle(mutableMapOf()))
}
@Test
fun `sets the result when an input changes`() {
viewModel.v1 = "10"
viewModel.v2 = "20"
assertThat(viewModel.result).isEqualTo("30")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment