package Ġca . c ply on . co int ime . ui . detail Ċ Ċ import Ġandroid . graphics . Bitmap Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġca . c ply on . co int ime . Fake Coin Time Application Instrumentation Ċ import Ġca . c ply on . co int ime . data . Coin Ċ import Ġca . c ply on . co int ime . data . source . Fake Coin Repository Instrumentation Ċ import Ġorg . hamcrest . core . String EndsWith Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠCoin Detail ViewModel Instrumentation Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfake Repository : ĠFake Coin Repository Instrumentation ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġvm : ĠCoin Detail ViewModel ĊĠĠĠ Ġprivate Ġval Ġcoins Ġ= ĠlistOf ( Coin (" Dummy ", Ġ" Dummy ", Ġ 0 , Ġ" Dummy ", Ġ" Dummy ")) ĊĠĠĠ Ġprivate Ġval Ġbitmap Ġ= ĠBitmap . create Bitmap ( 1 , Ġ 1 , ĠBitmap . Config . ARGB _ 8 8 8 8 ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp ViewModel () Ġ{ ĊĠĠĠĠĠĠĠ Ġfake Repository Ġ= ĠFake Coin Repository Instrumentation ( coins ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave Ob verse Image _ failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġfake Repository . return Error Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġvm Ġ= ĠCoin Detail ViewModel ( fake Repository , ĠFake Coin Time Application Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġvm . save Ob verse Image ( bitmap ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNull ( fileName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave Reverse Image _ failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġfake Repository . return Error Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġvm Ġ= ĠCoin Detail ViewModel ( fake Repository , ĠFake Coin Time Application Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġvm . save Reverse Image ( bitmap ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNull ( fileName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave Ob verse Image _ success () Ġ{ ĊĠĠĠĠĠĠĠ Ġfake Repository . return Error Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġvm Ġ= ĠCoin Detail ViewModel ( fake Repository , ĠFake Coin Time Application Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġvm . save Ob verse Image ( bitmap ) ĊĠĠĠĠĠĠĠ ĠAssert . assertThat ( fileName , ĠString EndsWith ("_ ob verse . png ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave Reverse Image _ success () Ġ{ ĊĠĠĠĠĠĠĠ Ġfake Repository . return Error Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġvm Ġ= ĠCoin Detail ViewModel ( fake Repository , ĠFake Coin Time Application Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval ĠfileName Ġ= Ġvm . save Reverse Image ( bitmap ) ĊĠĠĠĠĠĠĠ ĠAssert . assertThat ( fileName , ĠString EndsWith ("_ reverse . png ")) ĊĠĠĠ Ġ} Ċ } Ċ