package Ġcom . robert om ir anda . app . features . post list Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . paging . Paged List Ċ import Ġcom . robert om ir anda . app . Rx Base Test Ċ import Ġcom . robert om ir anda . app . core . Post List Screen State Ċ import Ġcom . robert om ir anda . app . core . Screen State Ċ import Ġcom . robert om ir anda . app . features . post list . data . Post List Provider Ċ import Ġcom . robert om ir anda . app . utils . as Paged List Ċ import Ġcom . robert om ir anda . data . models . Post Ċ import Ġio . mock k . confirm Verified Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġio . reactivex . Flow able Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ Ċ class ĠPost List ViewModel Test Ġ: ĠRx Base Test () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠPost List ViewModel ĊĠĠĠ Ġprivate Ġval Ġprovider : ĠPost List Provider Ġ= Ġmock k < Post List Provider >() ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġinstant Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġoverride Ġfun ĠsetUp Child () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp Child () ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠPost List ViewModel ( provider ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Post OK () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġ( 0 .. 1 0 ). map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPost ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" s unt Ġaut Ġfac ere Ġrep ell at Ġpro vid ent Ġoccaec ati Ġexcept uri Ġopt io Ġreprehenderit ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it Ġ% Ġ 9 Ġ== Ġ 0 ) Ġ 1 Ġelse Ġit Ġ% Ġ 9 , Ġit , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" quia Ġet Ġsus cipit \ ns us cipit Ġre cus and ae Ġconsequ unt ur Ġexp edit a Ġet Ġcum \ n re pre henderit Ġmolest ia e Ġut Ġut Ġqu as Ġtot am \ n no str um Ġrer um Ġest Ġaut em Ġsunt Ġrem Ġeven iet Ġarchitect o " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ}. as Paged List () ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Observer : ĠObserver < Paged List < Post >> Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġscreen Observer : ĠObserver < Screen State > Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġprovider . getAll Post Pag inated () Ġ} Ġreturns ĠFlow able . just ( data ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . observe Fore ver ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . observe Fore ver ( list Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . load Post List () ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . INITIAL ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . LOADING _ DATA ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġprovider . getAll Post Pag inated () Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġlist Observer . on Changed ( data ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . DATA _ LOADED ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġconfirm Verified ( screen Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( list Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( provider ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . remove Observer ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . remove Observer ( list Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Post Empty OK () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġempty List < Post >(). as Paged List () ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Observer : ĠObserver < Paged List < Post >> Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġscreen Observer : ĠObserver < Screen State > Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġprovider . getAll Post Pag inated () Ġ} Ġreturns ĠFlow able . just ( data ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . observe Fore ver ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . observe Fore ver ( list Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . load Post List () ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . INITIAL ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . LOADING _ DATA ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġprovider . getAll Post Pag inated () Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . EMPTY _ DATA ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġconfirm Verified ( screen Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( list Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( provider ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . remove Observer ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . remove Observer ( list Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Post KO () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġerror Ġ= ĠException (" My Ġerror ") ĊĊĠĠĠĠĠĠĠ Ġval Ġlist Observer : ĠObserver < Paged List < Post >> Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġscreen Observer : ĠObserver < Screen State > Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġprovider . getAll Post Pag inated () Ġ} Ġreturns ĠFlow able . error ( error ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . observe Fore ver ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . observe Fore ver ( list Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . load Post List () ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . INITIAL ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . LOADING _ DATA ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġprovider . getAll Post Pag inated () Ġ} ĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġscreen Observer . on Changed ( Post List Screen State . ERROR ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġconfirm Verified ( screen Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( list Observer ) ĊĠĠĠĠĠĠĠ Ġconfirm Verified ( provider ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . screen State . remove Observer ( screen Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . post List . remove Observer ( list Observer ) ĊĠĠĠ Ġ} Ċ }