Skip to content

Instantly share code, notes, and snippets.

@orcchg
Created June 26, 2021 20:48
Show Gist options
  • Select an option

  • Save orcchg/d5ebab6c5e8390b87f147ba9f78c05fb to your computer and use it in GitHub Desktop.

Select an option

Save orcchg/d5ebab6c5e8390b87f147ba9f78c05fb to your computer and use it in GitHub Desktop.
class TestStockListViewModel {
@Inject internal lateinit var viewModel: StockListViewModel
@get:Rule val instantExecutorRule = InstantTaskExecutorRule()
private val featureApi: TestStockListFeatureComponent =
DaggerTestStockListFeatureComponent.create()
init {
featureApi.inject(this)
}
@Test
fun `test get stocks`() {
val actualTickers = viewModel.stocks.value?.map { it.ticker }
val expectedTickers = featureApi.interactor
.stocks()
.blockingGet()
.map { it.ticker }
Assert.assertNotNull(expectedTickers)
Assert.assertNotNull(actualTickers)
Assert.assertArrayEquals(
expectedTickers.toTypedArray(),
actualTickers!!.toTypedArray()
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment