package Ġnl . ent re co . dart ss core card . play . score Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . res . Resources Ċ import Ġandroid . view . View Property Animator Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġorg . mockito . kotlin .* Ċ import Ġnl . ent re co . dart ss core card . R Ċ import Ġnl . ent re co . dart ss core card . base . widget . Counter TextView Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Additional Matchers .* Ċ import Ġorg . mockito . Argument Matchers . any Int Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠEnt re co Ġon Ġ 2 8 / 1 1 / 2 0 1 7 . Ċ Ġ*/ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠTeam Score Bindings Test Ġ{ ĊĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock Counter TextView : ĠCounter TextView ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock Context : ĠContext ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock Theme : ĠResources . Theme ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock TextView : ĠTextView ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock ImageView : ĠImageView ĊĠĠĠ Ġ@ Mock Ġprivate Ġlateinit Ġvar Ġmock Animator : ĠView Property Animator ĊĠĠĠ Ġprivate Ġval Ġrunnable Ġ= Ġargument Captor < Runnable >() ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġset Target () Ġon ĠCounter TextView Ġ( Score Pts ĠTextView )` () Ġ{ ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Score ( mock Counter TextView , Ġ 5 0 ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Counter TextView ). setTarget ( 5 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġset Ġ' starter ' Ġdrawable Ġwhen Ġplayer Ġis Ġstarting Ġplayer `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Player Started Leg () ĊĠĠĠĠĠĠĠ Ġthen Starter Drawable Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġclear Ġ' starter ' Ġdrawable Ġwhen Ġplayer Ġis Ġ! starting Ġplayer `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Player Was Not Starting () ĊĠĠĠĠĠĠĠ Ġthen Starter Drawable IsNot Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠNullPointerException :: class ) ĊĠĠĠ Ġfun Ġ` it Ġshould Ġhandle Ġ 9 - dar ter Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven N ine Dart Event ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠNullPointerException :: class ) ĊĠĠĠ Ġfun Ġ` it Ġshould Ġclear Ġ 9 - dar ter Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven N ine Dart Event ( false ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġshow Ġspecial s Ġwhen Ġscoring Ġ 1 8 0 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Special Score ( 1 8 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġthen 1 8 0 Animation Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould ĠNOT Ġshow Ġspecial s Ġwhen Ġscoring Ġ 0 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Special Score ( 0 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġthen No Animation Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġclear Ġspecial s Ġwhen Ġscoring Ġall Ġothers `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Special Score ( 1 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġthen Clear Animation Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġshow Ġcurrent Ġscore Ġanimation Ġgt Ġ 0 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Current Score ( 1 0 0 ) ĊĠĠĠĠĠĠĠ Ġthen Show Current Animation Is Done () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġhide Ġcurrent Ġscore Ġanimation Ġlt Ġ 0 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Current Score ( 0 ) ĊĠĠĠĠĠĠĠ Ġthen Hide Current Animation Is Done () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġshow Ġcurrent Ġteam Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Current Team ( true ) ĊĠĠĠĠĠĠĠ Ġthen Current Team Animation Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` it Ġshould Ġclear Ġcurrent Ġteam Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Current Team ( false ) ĊĠĠĠĠĠĠĠ Ġthen Current Team Animation Is Hidden () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠNullPointerException :: class ) Ġ// ĠUnable Ġto Ġmock Ġandroid . graphics . Color ĊĠĠĠ Ġfun Ġ` it Ġshould Ġshow Ġfinish Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Finish (" T 2 0 ĠD 1 0 ") ĊĠĠĠĠĠĠĠ Ġthen Finish Animation Is Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠNullPointerException :: class ) ĊĠĠĠ Ġfun Ġ` it Ġshould Ġhide Ġfinish Ġanimation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven Finish ("") ĊĠĠĠĠĠĠĠ Ġthen Finish Animation IsNot Shown () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Special Score ( old Score : ĠInt , Ġscore : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock TextView . animate ()). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġmock Animations () ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Special s ( mock TextView , Ġold Score , Ġscore ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven N ine Dart Event ( n ine D arts : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock TextView . width ). thenReturn ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock TextView . meas ured Width ). thenReturn ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġmock Animations () ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show N ine D arter ( mock TextView , Ġn ine D arts ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Current Score ( score : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Counter TextView . animate ()). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Counter TextView . context ). thenReturn ( mock Context ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Context . theme ). thenReturn ( mock Theme ) ĊĠĠĠĠĠĠĠ Ġmock Animations () ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Current Score ( mock Counter TextView , Ġscore ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Counter TextView ). setTarget ( score . to Long ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Current Team ( current : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock ImageView . animate ()). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock ImageView . width ). thenReturn ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġmock Animations () ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Current Team ( mock ImageView , Ġcurrent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Finish ( finish : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock TextView . width ). thenReturn ( 2 0 0 ) ĊĠĠĠĠĠĠĠ Ġmock Animations () ĊĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Finish With Alpha ( mock TextView , Ġfinish , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Player Was Not Starting () Ġ{ ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Starting Player ( mock TextView , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Player Started Leg () Ġ{ ĊĠĠĠĠĠĠĠ ĠTeam Score Bindings . show Starting Player ( mock TextView , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Starter Drawable Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView ). set Compound Draw ables With Intr insic Bounds ( 0 , Ġ 0 , ĠR . drawable . starter , Ġ 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Starter Drawable IsNot Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView ). set Compound Draw ables With Intr insic Bounds ( 0 , Ġ 0 , Ġ 0 , Ġ 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen 1 8 0 Animation Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView ). setText ( R . string . score _ 1 8 0 ) ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView , Ġat Least Once ()). animate () ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). with Start Action ( run nable . capture ()) ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). with End Action ( run nable . capture ()) ĊĠĠĠĠĠĠĠ Ġrunnable . all Values . forEach Ġ{ Ġit . run () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen No Animation Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView , Ġnever ()). setText ( R . string . score _ 1 8 0 ) ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView , Ġnever ()). animate () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Clear Animation Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView , Ġnever ()). setText ( R . string . score _ 1 8 0 ) ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView , Ġtimes ( 1 )). animate () ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). with Start Action ( run nable . capture ()) ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). with End Action ( run nable . capture ()) ĊĠĠĠĠĠĠĠ Ġrunnable . all Values . forEach Ġ{ Ġit . run () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Show Current Animation Is Done () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock Counter TextView ). animate () ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). start () ĊĠĠĠĠĠĠĠ Ġverify ( mock Counter TextView ). setTextColor ( any Int ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Hide Current Animation Is Done () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock Counter TextView , Ġnever ()). setTextColor ( any Int ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Current Team Animation Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock ImageView ). animate () ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). translation X ( 0 f ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Current Team Animation Is Hidden () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock ImageView ). animate () ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). translation X ( gt ( 1 0 F )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Finish Animation Is Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView ). text Ġ= Ġnot ( eq ("")) ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). translation X ( eq ( 0 F )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġthen Finish Animation IsNot Shown () Ġ{ ĊĠĠĠĠĠĠĠ Ġverify ( mock TextView ). text Ġ= Ġeq ("") ĊĠĠĠĠĠĠĠ Ġverify ( mock Animator ). translation X ( lt ( 0 F )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmock Animations () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . translation X ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . scale Y ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . set Interpolator ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . set Start Delay ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . set Duration ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . with Start Action ( any ())). thenReturn ( mock Animator ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Animator . with End Action ( any ())). thenReturn ( mock Animator ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ