package Ġcom . zg . bur ger joint . mvp . present ers . impl s Ċ Ċ import Ġandroid . widget . ImageView Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . lifecycle . Lifecycle Owner Ċ import Ġandroidx . lifecycle . Lifecycle Registry Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . zg . bur ger joint . data . model . Bur ger Model Ċ import Ġcom . zg . bur ger joint . data . model . impl s . Bur ger Model Impl Ċ import Ġcom . zg . bur ger joint . data . model . impl s . Mock Bur ger Model Impl Ċ import Ġcom . zg . bur ger joint . data . v os . Bur ger VO Ċ import Ġcom . zg . bur ger joint . dummy . get Dummy Bur gers Ċ import Ġcom . zg . bur ger joint . mvp . views . Main View Ċ import Ġio . mock k . Mock K Annotations Ċ import Ġio . mock k . impl . annotations . Rel ax ed Mock K Ċ import Ġio . mock k . verify Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . mock Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠP hy oe ĠS andy ĠSo e ĠT un Ċ Ġ* Ġon Ġ 7 / 1 3 / 2 0 2 0 . Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠMain Presenter Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Presenter : ĠMain Presenter Impl ĊĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm View : ĠMain View ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Bur ger Model : ĠBur ger Model ĊĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp Presenter () Ġ{ ĊĠĠĠĠĠĠĠ ĠMock K Annotations . init ( this ) ĊĊĠĠĠĠĠĠĠ ĠBur ger Model Impl . init ( Application Provider . getApplicationContext ()) ĊĠĠĠĠĠĠĠ Ġm Bur ger Model Ġ= ĠMock Bur ger Model Impl ĊĊĠĠĠĠĠĠĠ Ġm Presenter Ġ= ĠMain Presenter Impl () ĊĠĠĠĠĠĠĠ Ġm Presenter . init Presenter ( m View ) ĊĠĠĠĠĠĠĠ Ġm Presenter . m Bur ger Model Ġ= Ġthis . m Bur ger Model ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠonTap AddTo Cart _ call Add Bur ger To Cart () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġt apped Bur ger Ġ= ĠBur ger VO () ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Id Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Name Ġ= Ġ" Big ĠMac " ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger ImageUrl Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Description Ġ= Ġ" Big ĠMac ĠBur ger " ĊĊĠĠĠĠĠĠĠ Ġval ĠimageView Ġ= ĠImageView ( Application Provider . getApplicationContext ()) ĊĊĠĠĠĠĠĠĠ Ġm Presenter . on Tap AddTo Cart ( t apped Bur ger , ĠimageView ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm View . animate Add Bur ger To Cart ( t apped Bur ger , ĠimageView ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠonTap Cart _ call Navigate To Cart Screen () Ġ{ ĊĠĠĠĠĠĠĠ Ġm Presenter . on Tap Cart () ĊĠĠĠĠĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm View . navigate To Cart Screen () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠonTap Bur ger _ call Navigate To Bur ger Details () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġt apped Bur ger Ġ= ĠBur ger VO () ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Id Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Name Ġ= Ġ" Big ĠMac " ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger ImageUrl Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġt apped Bur ger . bur ger Description Ġ= Ġ" Big ĠMac ĠBur ger " ĊĠĠĠĠĠĠĠ Ġval ĠimageView Ġ= ĠImageView ( Application Provider . getApplicationContext ()) ĊĊĠĠĠĠĠĠĠ Ġm Presenter . on Tap Bur ger ( t apped Bur ger , ĠimageView ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm View . navigate To Bur ger Details Screen With Animation ( t apped Bur ger . bur ger Id , ĠimageView ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon UI Ready _ call Display Bur ger List _ call Display Count In Cart () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġmock Ġlifecycle owner ĊĠĠĠĠĠĠĠ Ġval Ġlife Cycle Owner Ġ= Ġmock ( Lifecycle Owner :: class . java ) ĊĠĠĠĠĠĠĠ Ġ// Ġcreate Ġresume Ġstate ĊĠĠĠĠĠĠĠ Ġval Ġlife Cycle Registry Ġ= ĠLifecycle Registry ( life Cycle Owner ) ĊĠĠĠĠĠĠĠ Ġlife Cycle Registry . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) ĊĠĠĠĠĠĠĠ Ġ` when `( life Cycle Owner . lifecycle ). thenReturn ( life Cycle Registry ) ĊĊĠĠĠĠĠĠĠ Ġm Presenter . on UI Ready ( life Cycle Owner ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġm View . display Bur ger List ( get Dummy Bur gers ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĊĊĊĊ Ċ }