package Ġorg . simple . clin ic . select state Ċ Ċ 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 Ġorg . junit . After Ċ import Ġorg . junit . Test Ċ import Ġorg . simple . shared Test Code . TestData Ċ import Ġorg . simple . clin ic . app config . AppConfig Repository Ċ import Ġorg . simple . clin ic . app config . States Result Ċ import Ġorg . simple . clin ic . app config . States Result . Fetch Error Ċ import Ġorg . simple . clin ic . mob ius . Effect Handler TestCase Ċ import Ġorg . simple . clin ic . util . Resolved Error . Network Related Ċ import Ġorg . simple . clin ic . util . scheduler . Test Schedulers Provider Ċ Ċ class ĠSelect State Effect Handler Test Ġ{ ĊĊĠ Ġprivate Ġval Ġui Actions Ġ= Ġmock < Select State Ui Actions >() ĊĠ Ġprivate Ġval Ġapp Config Repository Ġ= Ġmock < AppConfig Repository >() ĊĠ Ġprivate Ġval Ġview Effect Handler Ġ= ĠSelect State View Effect Handler ( ui Actions ) ĊĠ Ġprivate Ġval Ġeffect Handler Ġ= ĠSelect State Effect Handler ( ĊĠĠĠĠĠ Ġapp Config Repository Ġ= Ġapp Config Repository , ĊĠĠĠĠĠ Ġs chedulers Ġ= ĠTest Schedulers Provider . tr amp oline (), ĊĠĠĠĠĠ Ġview Effects Consumer Ġ= Ġview Effect Handler :: handle ĊĠ Ġ) ĊĠ Ġprivate Ġval ĠtestCase Ġ= ĠEffect Handler TestCase ( effect Handler . build ()) ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ ĠtestCase . dispose () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġloading Ġstates Ġis Ġsuccessful , Ġthen Ġstates Ġfetched Ġevent Ġshould Ġbe Ġemitted `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġstates Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠTest Data . state ( displayName Ġ= Ġ" And h ra ĠPr ade sh "), ĊĠĠĠĠĠĠĠ ĠTest Data . state ( displayName Ġ= Ġ" Ker ala ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġwhenever ( app Config Repository . fetch States In Selected Country ()) Ġdo Return ĠStates Result . States F etched ( states ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Load States ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert Outgoing Events ( States F etched ( states )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġloading Ġstates Ġfails , Ġthen Ġfailed Ġto Ġfetch Ġstates Ġevent Ġshould Ġbe Ġemitted `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġerror Ġ= ĠStates Fetch Error . Network Error ĊĊĠĠĠ Ġwhenever ( app Config Repository . fetch States In Selected Country ()) Ġdo Return ĠFetch Error ( Network Related ( RuntimeException ())) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Load States ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert Outgoing Events ( Failed To Fetch States ( error )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġsave Ġstate Ġeffect Ġis Ġreceived , Ġthen Ġsave Ġstate Ġto Ġlocal Ġpersistence `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġdeployment Ġ= ĠTest Data . deployment ( ĊĠĠĠĠĠĠĠ ĠdisplayName Ġ= Ġ" IH CI ", ĊĠĠĠĠĠĠĠ Ġend Point Ġ= Ġ" https :// simple . org " ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġstate Ġ= ĠTest Data . state ( displayName Ġ= Ġ" And h ra ĠPr ade sh ", Ġdeployment Ġ= Ġdeployment ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Save Selected State ( state )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert Outgoing Events ( State Saved ) ĊĊĠĠĠ Ġverify ( app Config Repository ). save State ( state ) ĊĠĠĠ Ġverify ( app Config Repository ). save Deployment ( deployment ) ĊĠĠĠ Ġverify No More Interactions ( app Config Repository ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġgo Ġto Ġregistration Ġscreen Ġeffect Ġis Ġreceived , Ġthen Ġgo Ġto Ġregistration Ġscreen `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Go To Registration Screen ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( ui Actions ). goTo Registration Screen () ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġreplace Ġcurrent Ġscreen Ġto Ġregistration Ġscreen Ġeffect Ġis Ġreceived , Ġthen Ġreplace Ġcurrent Ġscreen Ġwith Ġregistration Ġscreen `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ ĠtestCase . dispatch ( Replace Current Screen With Registration Screen ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠtestCase . assert No Outgoing Events () ĊĊĠĠĠ Ġverify ( ui Actions ). replace Current Screen To Registration Screen () ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} Ċ } Ċ