package Ġcom . dou glas . github auth . module . core Ċ Ċ import Ġandroid . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . dou glas . github auth . Test Observer Ċ import Ġcom . dou glas . github auth . domain . Check Login UseCase Ċ import Ġcom . dou glas . github auth . test Observer Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito Annotations Ċ Ċ class ĠCore ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġtask Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġcheck Login UseCase : ĠCheck Login UseCase ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtarget : ĠCore ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview State Store : ĠTest Observer < Core ViewModel . ViewState > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĊĠĠĠĠĠĠĠ Ġtarget Ġ= ĠCore ViewModel ( check Login UseCase ) ĊĠĠĠĠĠĠĠ Ġview State Store Ġ= Ġtarget . view State . test Observer () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġhas Ġno Ġuser Ġlogged Ġin `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( check Login UseCase . has User Logged ()). thenReturn ( false ) ĊĊĠĠĠĠĠĠĠ Ġtarget . check If Has User LoggedIn () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġview State Store . observed Values . count ()) ĊĠĠĠĠĠĠĠ Ġassert ( view State Store . observed Values [ 0 ] Ġis ĠCore ViewModel . ViewState . Show Login Screen ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġhas Ġuser Ġlogged Ġin `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( check Login UseCase . has User Logged ()). thenReturn ( true ) ĊĊĠĠĠĠĠĠĠ Ġtarget . check If Has User LoggedIn () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġview State Store . observed Values . count ()) ĊĠĠĠĠĠĠĠ Ġassert ( view State Store . observed Values [ 0 ] Ġis ĠCore ViewModel . ViewState . Show Profile Screen ) ĊĠĠĠ Ġ} Ċ }