package Ġcom . te o . recipes . ui Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . te o . recipes . meal . data . Me al Repository Ċ import Ġcom . te o . recipes . meal . ui . Me al ViewModel Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġorg . hamcrest . Core Matchers . notNull Value Ċ import Ġorg . hamcrest . Core Matchers . null Value Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġorg . mockito . Mockito .* Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠMe al ViewModel Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcategory Ġ= Ġ" test " ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġinstant Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġcoroutine Scope Ġ= ĠCor outine Scope ( Dispatch ers . IO ) ĊĊĠĠĠ Ġprivate Ġval Ġrepository Ġ= Ġmock ( Me al Repository :: class . java ) ĊĠĠĠ Ġprivate Ġvar ĠviewModel Ġ= ĠMe al ViewModel ( repository , Ġcoroutine Scope ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Null () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat ( viewModel . str Category , Ġnull Value ()) ĊĠĠĠĠĠĠĠ Ġ// ĠassertThat ( viewModel . connectivity Available , Ġnot NullValue ()) ĊĠĠĠĠĠĠĠ Ġverify ( repository , Ġnever ()). observe Me als By Category ( category ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdo Not Fetch Without Observer s () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . str Category Ġ= Ġcategory ĊĠĠĠĠĠĠĠ Ġverify ( repository , Ġnever ()). observe Me als By Category ( category ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdo Not Fetch Without Observer On Connection Change () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . str Category Ġ= Ġcategory ĊĊĠĠĠĠĠĠĠ Ġverify ( repository , Ġnever ()). observe Me als By Category ( category ) ĊĊĠĠĠ Ġ} Ċ }