package Ġcom . ky lix . submission b aj p 2 . view model Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . ky lix . submission b aj p 2 . Fake Data Ċ import Ġcom . ky lix . submission b aj p 2 . model . repository . Data Repository Ċ import Ġcom . ky lix . submission b aj p 2 . model . repository . remote . ItemList Ċ import Ġcom . ky lix . submission b aj p 2 . model . repository . remote . Tv Show Detail Ċ import Ġcom . ky lix . submission b aj p 2 . ui . tv show . Tv Show ViewModel Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito Ċ Ċ class ĠT v Show ViewModel Test Ġ{ ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġvar ĠviewModel : ĠT v Show ViewModel ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġvar Ġdata Ġ= ĠMockito . mock ( Data Repository :: class . java ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp (){ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠT v Show ViewModel ( data ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Tv Show List (){ ĊĠĠĠĠĠĠĠ Ġval Ġtv Show Ġ= ĠMutable LiveData < List < ItemList >>() ĊĠĠĠĠĠĠĠ Ġtv Show . value Ġ= ĠFake Data . get Dummy Remote Movie () ĊĠĠĠĠĠĠĠ ĠMockito .` when `( data . get Tv Show ()). thenReturn ( tv Show ) ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠMockito . mock ( Observer :: class . java ) ĊĠĠĠĠĠĠĠ ĠviewModel ?. tv Show ?. observe Fore ver ( observer Ġas ĠObserver < List < ItemList >>) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( data ). get Tv Show () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Tv Show Detail (){ ĊĠĠĠĠĠĠĠ Ġval Ġtv Show Ġ= ĠMutable LiveData < Tv Show Detail >() ĊĠĠĠĠĠĠĠ Ġtv Show . value Ġ= ĠFake Data . get Tv Show Detail () ĊĠĠĠĠĠĠĠ ĠMockito .` when `( data . get Tv Show Detail ( tv Show . value !!. id . toString ())). thenReturn ( tv Show ) ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠMockito . mock ( Observer :: class . java ) ĊĠĠĠĠĠĠĠ ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. observe Fore ver ( observer Ġas ĠObserver < Tv Show Detail >) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( data ). get Tv Show () ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( tv Show . value !!. id , ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. value ?. id ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( tv Show . value !!. name , ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. value ?. name ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( tv Show . value !!. overview , ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. value ?. overview ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( tv Show . value !!. poster Path , ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. value ?. poster Path ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( tv Show . value !!. first Air Date , ĠviewModel ?. get Tv Show Detail ( tv Show . value !!. id . toString ()) ?. value ?. first Air Date ) ĊĠĠĠ Ġ} Ċ }