package Ġcom . nor ane ko it . b aj p . moe . ui . favorite Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . paging . Paged List Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġcom . nor ane ko it . b aj p . moe . data . source . Movie Repository Ċ import Ġcom . nor ane ko it . b aj p . moe . data . source . local . entity . Movie Entity Ċ import Ġcom . nor ane ko it . b aj p . moe . data . source . local . entity . Tv Entity Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠF avorite ViewModel Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfavorite ViewModel : ĠF avorite ViewModel ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmovie Repository : ĠMovie Repository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmovie Observer : ĠObserver < Paged List < Movie Entity >> ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmovie Paged List : ĠP aged List < Movie Entity > ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtv Observer : ĠObserver < Paged List < Tv Entity >> ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtv Paged List : ĠP aged List < Tv Entity > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġfavorite ViewModel Ġ= ĠF avorite ViewModel ( movie Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Ġfavorite ĠMovie `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdummy Movie Ġ= Ġmovie Paged List ĊĠĠĠĠĠĠĠ Ġ` when `( dummy Movie . size ). thenReturn ( 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġmovie Ġ= ĠMutable LiveData < Paged List < Movie Entity >>() ĊĠĠĠĠĠĠĠ Ġmovie . value Ġ= Ġdummy Movie ĊĠĠĠĠĠĠĠ Ġ` when `( movie Repository . getF avorites Movies ()). thenReturn ( movie ) ĊĠĠĠĠĠĠĠ Ġval Ġmovie Entity Ġ= Ġfavorite ViewModel . get Favorite Movie (). value ĊĠĠĠĠĠĠĠ Ġverify ( movie Repository ). getF avorites Movies () ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( movie Entity ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 4 , Ġmovie Entity ?. size ) ĊĠĠĠĠĠĠĠ Ġfavorite ViewModel . get Favorite Movie (). observe Fore ver ( movie Observer ) ĊĠĠĠĠĠĠĠ Ġverify ( movie Observer ). on Changed ( dummy Movie ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Ġfavorite ĠT v ĠShow `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdummy Tv Ġ= Ġtv Paged List ĊĠĠĠĠĠĠĠ Ġ` when `( dummy Tv . size ). thenReturn ( 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġtv Ġ= ĠMutable LiveData < Paged List < Tv Entity >>() ĊĠĠĠĠĠĠĠ Ġtv . value Ġ= Ġdummy Tv ĊĠĠĠĠĠĠĠ Ġ` when `( movie Repository . getF avorites Tv Shows ()). thenReturn ( tv ) ĊĠĠĠĠĠĠĠ Ġval Ġtv Entity Ġ= Ġfavorite ViewModel . get Favorite Tv Show (). value ĊĠĠĠĠĠĠĠ Ġverify ( movie Repository ). getF avorites Tv Shows () ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( tv Entity ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 4 , Ġtv Entity ?. size ) ĊĠĠĠĠĠĠĠ Ġfavorite ViewModel . get Favorite Tv Show (). observe Fore ver ( tv Observer ) ĊĠĠĠĠĠĠĠ Ġverify ( tv Observer ). on Changed ( dummy Tv ) ĊĊĠĠĠ Ġ} Ċ Ċ }