package Ġcom . g rel a . clean . view model Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . g rel a . clean . Base UnitTest Ċ import Ġcom . g rel a . clean . Resource Ċ import Ġcom . g rel a . clean . model . Country Model Ċ import Ġcom . g rel a . clean . model . Country ViewModel Ċ import Ġcom . g rel a . data . datasource . Sport Remote DataSource Contract Ċ import Ġcom . g rel a . data . model . Country Data Entity Ċ import Ġcom . g rel a . domain . Data Result Ċ import Ġcom . g rel a . domain . Sport Repository Contract Ċ import Ġcom . g rel a . domain . inter actor . Get Country UseCase Ċ import Ġcom . g rel a . domain . inter actor . Invoker Ċ import Ġcom . g rel a . domain . model . Country Domain Entity Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . given Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Test Rule Ċ Ċ class ĠCountry View model Test Ġ: ĠBase UnitTest () Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġrule : ĠTest Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġget Countries Ġ= Ġmock < Get Country UseCase >() ĊĠĠĠ Ġprivate Ġval Ġcountry Repository Ġ= Ġmock < Sport Repository Contract >() ĊĠĠĠ Ġprivate Ġval Ġs port Remote DataSource Ġ= Ġmock < Sport Remote DataSource Contract >() ĊĠĠĠ Ġprivate Ġval Ġinvok er Ġ= Ġmock < Invoker >() ĊĠĠĠ Ġprivate Ġval Ġobserver Ġ= Ġmock < Observer < Resource < List < Country Model >>>> () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠCountry ViewModel ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠCountry ViewModel ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinvok er , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Countries ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠviewModel . country Models . observe Fore ver ( observer ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġshows Ġcountries Ġwhen Ġinter actor Ġreturns Ġcorrect Ġdata `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountries Ġ= ĠlistOf < Country Domain Entity >( mock ()) ĊĠĠĠĠĠĠĠ Ġval Ġcountries Data Ġ= ĠlistOf < Country Data Entity >( mock ()) ĊĠĠĠĠĠĠĠ Ġval Ġcountry Models Ġ= ĠlistOf < Country Model >( mock ()) ĊĊĠĠĠĠĠĠĠ Ġgiven ( country Repository . get Country ()). willReturn ( Data Result . Success ( countries )) ĊĠĠĠĠĠĠĠ Ġgiven ( sport Remote DataSource . getS port ()). willReturn ( Data Result . Success ( countries Data )) ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Countries . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . load () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( observer ). on Changed ( Resource . loading ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( observer ). on Changed ( Resource . success ( country Models )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }