package Ġcom . shop app . ui . category Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . support . v 7 . widget . Grid LayoutManager Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . times Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . shop app . Test Shop Application Ċ import Ġcom . shop app . gateway . entity . Category Ċ import Ġcom . shop app . test . Mock Instanti ator Ċ import Ġcom . shop app . ui . const . Constant . DEFAULT _ PER _ PAGE _ COUNT Ċ import Ġkotlinx . android . synt hetic . main . fragment _ search _ with _ categories _ list .* Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . Runtime Environment Ċ import Ġorg . ro bo lectric . Shadow s Ċ import Ġorg . ro bo lectric . annotation . Config Ċ import Ġorg . ro bo lectric . shadow s . support . v 4 . Support Fragment TestUtil Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ @ Config ( manifest Ġ= ĠConfig . NONE , Ġapplication Ġ= ĠTest Shop Application :: class ) Ċ class ĠCategory List Fragment Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfragment : ĠCategory List Fragment ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcontext : ĠContext ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġfragment Ġ= ĠCategory List Fragment () ĊĠĠĠĠĠĠĠ ĠSupport Fragment TestUtil . start Fragment ( fragment ) ĊĠĠĠĠĠĠĠ Ġcontext Ġ= ĠRuntime Environment . application . base Context ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Get Categories On Create () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( fragment . presenter ). get Category List ( DEFAULT _ PER _ PAGE _ COUNT , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Get Categories OnLoad Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġfragment . load Data () ĊĠĠĠĠĠĠĠ Ġverify ( fragment . presenter , Ġtimes ( 2 )). get Category List ( DEFAULT _ PER _ PAGE _ COUNT , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcategories Ġ= ĠMock Instanti ator . new List ( Mock Instanti ator . new Category (), ĠDEFAULT _ PER _ PAGE _ COUNT ) ĊĠĠĠĠĠĠĠ Ġfragment . show Content ( categories ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( DEFAULT _ PER _ PAGE _ COUNT , Ġfragment . re cyclerView . adapter . item Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Start Category Activity () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcategory : ĠCategory Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġfragment . on Item Clicked ( category , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġverify ( fragment . router ). show Category ( fragment . context , Ġcategory ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Show Items As Grid () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertTrue ( fragment . re cyclerView . layout Manager Ġis ĠGrid LayoutManager ) ĊĠĠĠ Ġ} Ċ }