package Ġorg . dh is 2 . use sc ases . te i Dashboard Ċ Ċ 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 . wh enever Ċ import Ġcom . squareup . sql br ite 2 . B rite Database Ċ import Ġio . reactivex . Single Ċ import Ġorg . dh is 2 . utils . Code Generator Ċ import Ġorg . h isp . dh is . android . core . D 2 Ċ import Ġorg . h isp . dh is . android . core . event . Event Ċ import Ġorg . h isp . dh is . android . core . program . Program Stage Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠDashboard Repository Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepository : ĠDashboard Repository Impl ĊĠĠĠ Ġprivate Ġval Ġcode Generator : ĠCode Generator Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġb rit ed atabase : ĠB rite Database Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġd 2 : ĠD 2 Ġ= Ġmock () ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠDashboard Repository Impl ( code Generator , Ġb rit ed atabase , Ġd 2 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġreturn Ġprogram Ġstage Ġto Ġshow Ġdisplay Ġgenerate Ġevent `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . event Module ()) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . event Module (). events ()) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . event Module (). events (). uid (" event _ uid ")) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . event Module (). events (). uid (" event _ uid "). get ()) Ġdo Return ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle . just ( getMock Single Event ()) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . program Module ()) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . program Module (). program Stages ()) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . program Module (). program Stages (). uid (" program _ stage ")) Ġdo Return Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( d 2 . program Module (). program Stages (). uid (" program _ stage "). get ()) Ġdo Return ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle . just ( getMock Stage ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= Ġrepository . display Generate Event (" event _ uid "). test () ĊĊĠĠĠĠĠĠĠ Ġtest Observer . assert No Errors () ĊĠĠĠĠĠĠĠ Ġtest Observer . assert Value Count ( 1 ) ĊĠĠĠĠĠĠĠ Ġtest Observer . assert Value ( getMock Stage ()) ĊĊĠĠĠĠĠĠĠ Ġtest Observer . dispose () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Mock Single Event (): ĠEvent Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠEvent . builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. uid (" event _ uid ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. program Stage (" program _ stage ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. program (" program ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Mock Stage (): ĠProgram Stage Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠProgram Stage . builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. uid (" program _ stage ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} Ċ } Ċ