package Ġorg . simple . clin ic . home Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . do Return Ċ 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 Ġcom . n ha ar man . mock it ok otlin 2 . verify No More Interactions Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . rx kotlin . of Type Ċ import Ġio . reactivex . subjects . Publish Subject Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . simple . clin ic . TestData Ċ import Ġorg . simple . clin ic . facility . Facility Ċ import Ġorg . simple . clin ic . over due . Appointment Repository Ċ import Ġorg . simple . clin ic . util . Rx Errors Rule Ċ import Ġorg . simple . clin ic . util . Test User Clock Ċ import Ġorg . simple . clin ic . util . scheduler . Test Schedulers Provider Ċ import Ġorg . simple . clin ic . widgets . Ui Event Ċ import Ġorg . simple . mob ius . migration . Mob ius TestFixture Ċ import Ġjava . time . LocalDate Ċ import Ġjava . util . UUID Ċ Ċ class ĠHome Screen Logic Test Ġ{ ĊĊĠ Ġ@ get : Rule ĊĠ Ġval Ġrx Errors Rule Ġ= ĠRx Errors Rule () ĊĊĠ Ġprivate Ġval Ġui Events : ĠPublish Subject < Ui Event > Ġ= ĠPublish Subject . create () ĊĊĠ Ġprivate Ġval Ġui Ġ= Ġmock < Home Screen Ui >() ĊĠ Ġprivate Ġval Ġui Actions Ġ= Ġmock < Home Screen Ui Actions >() ĊĠ Ġprivate Ġval Ġappointment Repository Ġ= Ġmock < Appointment Repository >() ĊĠ Ġprivate Ġval Ġclock Ġ= ĠTest User Clock () ĊĊĠ Ġprivate Ġlateinit Ġvar Ġtest Fixture : ĠMob ius TestFixture < Home Screen Model , ĠHome Screen Event , ĠHome Screen Effect > ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġtest Fixture . dispose () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġhome Ġscreen Ġis Ġcreated , Ġthen Ġsetup Ġthe Ġhome Ġscreen `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġfacility 1 Ġ= ĠTest Data . facility ( ĊĠĠĠĠĠĠĠ Ġuuid Ġ= ĠUUID . fromString (" de 2 5 0 4 4 5 - 0 ec 9 - 4 3 e 4 - be 3 3 - 2 a 4 9 ca 3 3 4 5 3 5 "), ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġ" CH C ĠB uch ho " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġfacility 2 Ġ= ĠTest Data . facility ( ĊĠĠĠĠĠĠĠ Ġuuid Ġ= ĠUUID . fromString (" 5 b 2 1 3 6 b 8 - 1 1 d 5 - 4 e 2 0 - 8 7 0 3 - 0 8 7 2 8 1 6 7 9 aee "), ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġ" CH C ĠN ath ana " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġdate Ġ= ĠLocalDate . parse (" 2 0 1 8 - 0 1 - 0 1 ") ĊĊĠĠĠ Ġwhenever ( appointment Repository . over due App ointments Count ( date , Ġfacility 1 )) Ġdo Return ĠObservable . just ( 3 ) ĊĠĠĠ Ġwhenever ( appointment Repository . over due App ointments Count ( date , Ġfacility 2 )) Ġdo Return ĠObservable . just ( 0 ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġsetup Controller ( Observable . just ( facility 1 , Ġfacility 2 )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( ui ). set Facility (" CH C ĠB uch ho ") ĊĠĠĠ Ġverify ( ui ). set Facility (" CH C ĠN ath ana ") ĊĠĠĠ Ġverify No More Interactions ( ui , Ġui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġfacility Ġchange Ġbutton Ġis Ġclicked Ġfacility Ġselection Ġscreen Ġshould Ġopen `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġfacility Ġ= ĠTest Data . facility ( ĊĠĠĠĠĠĠĠ Ġuuid Ġ= ĠUUID . fromString (" e 4 9 7 3 5 5 e - 7 2 3 c - 4 b 3 5 - b 5 5 a - 7 7 8 a 6 2 3 3 b 7 2 0 "), ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġ" CH C ĠB uch ho " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġdate Ġ= ĠLocalDate . parse (" 2 0 1 8 - 0 1 - 0 1 ") ĊĊĠĠĠ Ġwhenever ( appointment Repository . over due App ointments Count ( date , Ġfacility )) Ġdo Return ĠObservable . just ( 0 ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġsetup Controller ( Observable . just ( facility )) ĊĠĠĠ Ġui Events . onNext ( Home Facility Selection Clicked ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( ui ). set Facility (" CH C ĠB uch ho ") ĊĠĠĠ Ġverify ( ui Actions ). open Facility Selection () ĊĠĠĠ Ġverify No More Interactions ( ui , Ġui Actions ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġsetup Controller ( facility Stream : ĠObservable < Facility >) Ġ{ ĊĠĠĠ Ġclock . setDate ( LocalDate . parse (" 2 0 1 8 - 0 1 - 0 1 ")) ĊĊĠĠĠ Ġval Ġeffect Handler Ġ= ĠHome Screen Effect Handler ( ĊĠĠĠĠĠĠĠ Ġcurrent Facility Stream Ġ= Ġfacility Stream , ĊĠĠĠĠĠĠĠ Ġappointment Repository Ġ= Ġappointment Repository , ĊĠĠĠĠĠĠĠ Ġpatient Repository Ġ= Ġmock (), ĊĠĠĠĠĠĠĠ Ġuser Clock Ġ= Ġclock , ĊĠĠĠĠĠĠĠ Ġs chedulers Provider Ġ= ĠTest Schedulers Provider . tr amp oline (), ĊĠĠĠĠĠĠĠ Ġui Actions Ġ= Ġui Actions ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġui Renderer Ġ= ĠHome Screen Ui Renderer ( ui ) ĊĊĠĠĠ Ġtest Fixture Ġ= ĠMob ius TestFixture ( ĊĠĠĠĠĠĠĠ Ġevents Ġ= Ġui Events . of Type (), ĊĠĠĠĠĠĠĠ Ġdefault Model Ġ= ĠHome Screen Model . create (), ĊĠĠĠĠĠĠĠ Ġinit Ġ= ĠHome Screen Init (), ĊĠĠĠĠĠĠĠ Ġupdate Ġ= ĠHome Screen Update (), ĊĠĠĠĠĠĠĠ Ġeffect Handler Ġ= Ġeffect Handler . build (), ĊĠĠĠĠĠĠĠ Ġmodel Update Listener Ġ= Ġui Renderer :: render ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġtest Fixture . start () ĊĠ Ġ} Ċ } Ċ