package Ġcom . g scan lon 2 1 . reversed ictionary . repository . search Ċ Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . g scan lon 2 1 . reversed ictionary . Base UnitTest Ċ import Ġcom . g scan lon 2 1 . reversed ictionary . db . search . Word Of The Day Entity Ċ import Ġcom . g scan lon 2 1 . reversed ictionary . test . Test Coroutine Ċ import Ġcom . g scan lon 2 1 . reversed ictionary . test . Test Db Ċ import Ġcom . g scan lon 2 1 . reversed ictionary . test . Test Service Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . flow . toList Ċ import Ġkotlinx . coroutines . test . Test Coroutine Dispatcher Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġjava . time . Instant Ċ Ċ @ Experimental Cor outines Api Ċ class ĠGet Word Of The Day UnitTest Ġ: ĠBase UnitTest (), ĠTest Coroutine , ĠTest Db , ĠTest Service Ġ{ ĊĠĠĠ Ġoverride Ġval Ġtest Dispatcher : ĠTest Coroutine Dispatcher Ġ= ĠTest Coroutine Dispatcher () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġget Word Of The Day : ĠGet Word Of The Day ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠ Ġsetup Dependencies () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Dependencies () Ġ{ ĊĠĠĠĠĠĠĠ Ġget Word Of The Day Ġ= ĠGet Word Of The Day ( Application Provider . getApplicationContext (), Ġsearch Dao ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Should Fetch _ with Old Entry _ returns True () Ġ= Ġtest Dispatcher . run Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġsearch Dao . insert Word Of The Day ( Word Of The Day Entity (" Old ", ĠInstant . EPOCH )) ĊĊĠĠĠĠĠĠĠ Ġval Ġload From Db Ġ= Ġget Word Of The Day . load From Db () ĊĠĠĠĠĠĠĠ Ġassert ( load From Db . toList ( mutable ListOf ()) Ġ== ĠlistOf ( Word Of The Day Entity (" Old ", ĠInstant . EPOCH ))) ĊĊĠĠĠĠĠĠĠ Ġval Ġshould Fetch Ġ= Ġget Word Of The Day . should Fetch ( load From Db ) ĊĠĠĠĠĠĠĠ Ġassert ( should Fetch ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Should Fetch _ with No Entry _ returns True () Ġ= Ġtest Dispatcher . run Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġload From Db Ġ= Ġget Word Of The Day . load From Db () ĊĠĠĠĠĠĠĠ Ġassert ( load From Db . toList ( mutable ListOf ()) Ġ== ĠlistOf ( null )) ĊĊĠĠĠĠĠĠĠ Ġval Ġshould Fetch Ġ= Ġget Word Of The Day . should Fetch ( load From Db ) ĊĠĠĠĠĠĠĠ Ġassert ( should Fetch ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Should Fetch _ with New Entry _ returns False () Ġ= Ġtest Dispatcher . run Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnow Ġ= ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġsearch Dao . insert Word Of The Day ( Word Of The Day Entity (" New ", Ġnow )) ĊĊĠĠĠĠĠĠĠ Ġval Ġload From Db Ġ= Ġget Word Of The Day . load From Db () ĊĠĠĠĠĠĠĠ Ġassert ( load From Db . toList ( mutable ListOf ()) Ġ== ĠlistOf ( Word Of The Day Entity (" New ", Ġnow ))) ĊĊĠĠĠĠĠĠĠ Ġval Ġshould Fetch Ġ= Ġget Word Of The Day . should Fetch ( load From Db ) ĊĠĠĠĠĠĠĠ Ġassert (! should Fetch ) ĊĠĠĠ Ġ} Ċ } Ċ