package Ġio . github . well ing ton cost a . feed . app . ui . view model Ċ Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġio . github . well ing ton cost a . feed . app . ui . list posts . List Posts ViewModel Ċ import Ġio . github . well ing ton cost a . feed . domain . entity . Post Ċ import Ġio . github . well ing ton cost a . feed . domain . inter actor . Post Interactor Ċ import Ġio . github . well ing ton cost a . feed . mock . Post Mock . five Posts Ċ import Ġio . mock k . Runs Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . co Verify Ċ import Ġio . mock k . every Ċ import Ġio . mock k . just Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġorg . junit . Test Ċ Ċ class ĠList Posts ViewModel Test Ġ: ĠBase ViewModel Test () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġinter actor Ġ= Ġmock k < Post Interactor >() ĊĊĠĠĠ Ġprivate Ġval Ġloading Observer Ġ= Ġmock k < Observer < Boolean >>() ĊĊĠĠĠ Ġprivate Ġval Ġposts Observer Ġ= Ġmock k < Observer < List < Post >> >() ĊĊĠĠĠ Ġprivate Ġval Ġerror Observer Ġ= Ġmock k < Observer < Throwable >>() ĊĊĠĠĠ Ġprivate Ġval ĠviewModel Ġ= ĠList Posts ViewModel ( inter actor Ġ= Ġinter actor ) ĊĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġ@ Test Ġfun Ġ` no Ġinteractions `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġposts Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ ĠviewModel . posts . observe Fore ver ( posts Observer ) ĊĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġinter actor . getAll Posts () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġ@ Test Ġfun Ġ` get Ġposts Ġwith Ġsuccess `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġinter actor . getAll Posts () Ġ} Ġreturns Ġfive Posts ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġloading Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġposts Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ ĠviewModel . loading . observe Fore ver ( loading Observer ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . posts . observe Fore ver ( posts Observer ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . getAll Posts () ĊĊĠĠĠĠĠĠĠ Ġco Verify Ġ{ Ġinter actor . getAll Posts () Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 2 ) Ġ{ Ġloading Observer . on Changed ( any ()) Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġposts Observer . on Changed ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Experimental Cor outines Api ĊĠĠĠ Ġ@ Test Ġfun Ġ` throws Ġexception Ġwhen Ġget Ġposts `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġinter actor . getAll Posts () Ġ} Ġthrows ĠException () ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġloading Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġposts Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġerror Observer . on Changed ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ ĠviewModel . loading . observe Fore ver ( loading Observer ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . posts . observe Fore ver ( posts Observer ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . error . observe Fore ver ( error Observer ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . getAll Posts () ĊĊĠĠĠĠĠĠĠ Ġco Verify Ġ{ Ġinter actor . getAll Posts () Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 2 ) Ġ{ Ġloading Observer . on Changed ( any ()) Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġposts Observer . on Changed ( any ()) Ġ} ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġerror Observer . on Changed ( any ()) Ġ} ĊĠĠĠ Ġ} Ċ Ċ }