package Ġorg . simple . clin ic . summary . blood s ugar Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Return Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify No More Interactions Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Zero Interactions Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġio . reactivex . Observable Ċ import Ġorg . junit . Test Ċ import Ġorg . simple . clin ic . blood s ugar . Blood S ugar Measurement Ċ import Ġorg . simple . clin ic . blood s ugar . Blood S ugar Repository Ċ import Ġorg . simple . clin ic . blood s ugar . Random Ċ import Ġorg . simple . clin ic . mob ius . Effect Handler TestCase Ċ import Ġorg . simple . clin ic . patient . Patient M ocker Ċ import Ġorg . simple . clin ic . summary . Patient Summary Config Ċ import Ġorg . simple . clin ic . util . scheduler . Tr amp oline Schedulers Provider Ċ import Ġjava . util . UUID Ċ Ċ class ĠB lood S ugar Summary View Effect Handler Test Ġ{ ĊĊĠ Ġprivate Ġval Ġblood S ugar Repository Ġ= Ġmock < Blood S ugar Repository >() ĊĠ Ġprivate Ġval Ġui Actions Ġ= Ġmock < Ui Actions >() ĊĠ Ġprivate Ġval Ġconfig Ġ= Ġmock < Blood S ugar Summary Config >() ĊĠ Ġprivate Ġval Ġeffect Handler Ġ= ĠB lood S ugar Summary View Effect Handler ( ĊĠĠĠĠĠ Ġblood S ugar Repository , ĊĠĠĠĠĠ ĠTr amp oline Schedulers Provider (), ĊĠĠĠĠĠ Ġui Actions , ĊĠĠĠĠĠ Ġconfig ĊĠ Ġ). build () ĊĊĠ Ġprivate Ġval ĠtestCase Ġ= ĠEffect Handler TestCase ( effect Handler ) ĊĠ Ġprivate Ġval Ġpatient Uuid Ġ= ĠUUID . fromString (" 6 9 cde a 0 1 - fbd 8 - 4 3 7 a - 8 4 4 c - 2 5 e 4 1 2 f 3 2 a 9 e ") ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġfetch Ġblood Ġs ugar Ġeffect Ġis Ġreceived Ġthen Ġblood Ġs ugar Ġshould Ġbe Ġfetched `() Ġ{ ĊĠĠĠ Ġ// given ĊĠĠĠ Ġval Ġmeasurements Ġ= ĠlistOf < Blood S ugar Measurement >() ĊĠĠĠ Ġwhenever ( blood S ugar Repository . latest Measure ments ( patient Uuid Ġ= Ġpatient Uuid , Ġlimit Ġ= Ġconfig . numberOf Blood S ug ars To Display )). thenReturn ( Observable . just ( measure ments )) ĊĊĠĠĠ Ġ// when ĊĠĠĠ ĠtestCase . dispatch ( Fetch Blood S ugar Summary ( patient Uuid )) ĊĊĠĠĠ Ġ// then ĊĠĠĠ ĠtestCase . assert Outgoing Events ( Blood S ugar Summary F etched ( measure ments )) ĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġopen Ġblood Ġs ugar Ġtype Ġselector Ġeffect Ġis Ġreceived Ġthen Ġtype Ġselector Ġsheet Ġshould Ġbe Ġopened `() Ġ{ ĊĠĠĠ Ġ// when ĊĠĠĠ ĠtestCase . dispatch ( Open Blood S ugar Type Selector ) ĊĊĠĠĠ Ġ// then ĊĠĠĠ ĠtestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify ( ui Actions ). show Blood S ugar Type Selector () ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġload Ġblood Ġs ug ars Ġcount Ġeffect Ġis Ġreceived , Ġthen Ġload Ġblood Ġs ug ars Ġcount `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġblood S ug ars Count Ġ= Ġ 1 0 ĊĠĠĠ Ġwhenever ( blood S ugar Repository . blood S ug ars Count ( patient Uuid )) Ġdo Return ĠObservable . just ( blood S ug ars Count ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Fetch Blood S ugar Count ( patient Uuid )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert Outgoing Events ( Blood S ugar Count F etched ( blood S ug ars Count )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġshow Ġblood Ġs ugar Ġhistory Ġscreen Ġeffect Ġis Ġreceived , Ġthen Ġshow Ġblood Ġs ugar Ġhistory Ġscreen `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Show Blood S ugar History Screen ( patient Uuid )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify ( ui Actions ). show Blood S ugar History Screen ( patient Uuid ) ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġopen Ġblood Ġs ugar Ġupdate Ġsheet Ġeffect Ġis Ġreceived , Ġthen Ġopen Ġblood Ġs ugar Ġupdate Ġsheet `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġblood S ugar Ġ= ĠPatient M ocker . blood S ugar ( ĊĠĠĠĠĠĠĠ ĠUUID . fromString (" 3 be 6 5 af 9 - 3 2 4 f - 4 9 0 4 - 9 ab 4 - 6 d 8 c 4 7 9 4 1 b 9 9 "), ĊĠĠĠĠĠĠĠ Ġpatient Uuid Ġ= Ġpatient Uuid ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Open Blood S ugar Update Sheet ( blood S ugar )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify ( ui Actions ). open Blood S ugar Update Sheet ( blood S ugar . uuid , ĠRandom ) ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} Ċ } Ċ