package Ġbr . com . concrete . y ose f . property . color Ċ Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . graphics . drawable . Color Drawable Ċ import Ġandroid . support . test . Instrumentation Registry Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġandroid . support . v 7 . widget . Card View Ċ import Ġandroid . view . View Ċ import Ġbr . com . concrete . y ose f . api . property . color . BackgroundColor Command Ċ import Ġbr . com . concrete . y ose f . api . property . color . BackgroundColor Command . Companion . BACKGROUND _ COLOR Ċ import Ġbr . com . concrete . y ose f . entity . Dynamic Property Ċ import Ġbr . com . concrete . y ose f . layout And Assert Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . rules . Expected Exception Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠBackground Color Command Test Ġ{ ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġexception Rule : ĠExpected Exception Ġ= ĠExpected Exception . none () ĊĊĠĠĠ Ġprivate Ġval Ġcontext Ġ= ĠInstrument ation Registry . getTarget Context () !! ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠbackgroundColor Command : ĠBackground Color Command ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠbackgroundColor Command Ġ= ĠBackground Color Command () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrendering View Should Apply BackgroundColor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdynamic Property Ġ= ĠDynamic Property ( BACKGROUND _ COLOR , Ġ" color ", Ġ"# 0 0 0 0 FF ") ĊĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= ĠView ( context ) ĊĠĠĠĠĠĠĠ ĠbackgroundColor Command . apply ( view , Ġdynamic Property ) ĊĊĠĠĠĠĠĠĠ Ġview . layout And Assert Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġview BackgroundColor Ġ= Ġview . background Ġas ĠColor Drawable ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( view BackgroundColor . color Ġ== ĠColor . parse Color ( dynamic Property . value )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrendering View With Wrong Background Value Should Throw () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdynamic Property Ġ= ĠDynamic Property ( BACKGROUND _ COLOR , Ġ" color ", Ġ" wrong ") ĊĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= ĠView ( context ) ĊĊĠĠĠĠĠĠĠ Ġexception Rule . expect ( IllegalArgumentException :: class . java ) ĊĠĠĠĠĠĠĠ Ġexception Rule . expect Message (" The Ġvalue Ġ(${ dynamic Property . value }) Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" cannot Ġbe Ġparsed Ġas Ġa Ġcolor ") ĊĊĠĠĠĠĠĠĠ ĠbackgroundColor Command . apply ( view , Ġdynamic Property ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrendering Card View Should Apply BackgroundColor () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdynamic Property Ġ= ĠDynamic Property ( BACKGROUND _ COLOR , Ġ" color ", Ġ"# 0 0 0 0 FF ") ĊĊĠĠĠĠĠĠĠ Ġval Ġcard View Ġ= ĠCard View ( context ) ĊĠĠĠĠĠĠĠ ĠbackgroundColor Command . apply ( card View , Ġdynamic Property ) ĊĊĠĠĠĠĠĠĠ Ġcard View . layout And Assert Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġview BackgroundColor Ġ= Ġcard View . card BackgroundColor . default Color ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( view BackgroundColor Ġ== ĠColor . parse Color ( dynamic Property . value )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ