package Ġpri eto . fer n ando . data . repository Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . times Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Test Rule Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ import Ġpri eto . fer n ando . core _ android _ test . Main Coroutine Rule Ċ import Ġpri eto . fer n ando . data . Space X Remote Source Ċ import Ġpri eto . fer n ando . data . mapper . Company Info Repository To Domain Model Mapper Ċ import Ġpri eto . fer n ando . data . mapper . La unches Repository To Domain Model Mapper Ċ Ċ @ Experimental Cor outines Api Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠSpace X Repository Impl Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcut : ĠSpace X Repository Impl ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġspace X Remote Source : ĠSpace X Remote Source ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġcompany Info Domain Mapper : ĠCompany Info Repository To Domain Model Mapper ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġla unches Domain Mapper : ĠLa unches Repository To Domain Model Mapper ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġrule : ĠTest Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġval Ġmain Coroutine Rule Ġ= ĠMain Coroutine Rule () ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġcut Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSpace X Repository Impl ( space X Remote Source , Ġcompany Info Domain Mapper , Ġla unches Domain Mapper ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġget Company Info Ġthen Ġspace X Remote Source Ġinvoked `() Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠWhen ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( space X Remote Source . get Company Info ()). thenReturn ( mock ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcut . get Company Info () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( space X Remote Source , Ġtimes ( 1 )). get Company Info () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When ĠgetAll La unches Ġthen Ġspace X Remote Source Ġinvoked `() Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠWhen ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( space X Remote Source . getAll La unches ()). thenReturn ( mock ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcut . getAll La unches () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠThen ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( space X Remote Source , Ġtimes ( 1 )). getAll La unches () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ