package Ġcom . example . young ster _ b mi _ app . impl Ċ Ċ import Ġorg . junit . Test Ċ import Ġandroid . content . Context Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . example . young ster _ b mi _ app . R Ċ import Ġcom . example . young ster _ b mi _ app . model . Gender Ċ import Ġcom . example . young ster _ b mi _ app . model . Type Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . hamcrest . Core Matchers .* Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠCent ile Service Test Ġ{ ĊĠĠĠ Ġval Ġcontext Ġ= ĠApplication Provider . getApplicationContext < Context >() ĊĠĠĠ Ġval Ġtested Ġ= ĠCent ile Service ( context , Ġcontext . getString ( R . string . no Data For This Age Long )) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfind Cent ile () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtested . find Cent ile ( tested . getC ent iles (), ĠGender . BO Y , Ġ 6 0 , ĠType . HEIGHT Ġto Ġ 1 0 8 . 5 ) ĊĠĠĠĠĠĠĠ ĠassertThat (" Cent ile Ġwasn 't Ġcalculate Ġcorrectly ", Ġresult , Ġ` is `( 2 5 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Cent iles () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtested . getC ent iles () ĊĠĠĠĠĠĠĠ ĠassertThat (" Cent ile Ġdata Ġwasn 't Ġread ", Ġresult . size , Ġ` is `( not ( 0 ))) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġformat Cent iles () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġtested . format Cent ile ( context . getString ( R . string . cent ile Height ), ĠGender . BO Y , Ġ 6 0 , ĠType . HEIGHT Ġto Ġ 1 0 8 . 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= Ġcontext . getString ( R . string . cent ile Height ). plus (": Ġ 2 5 ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġresult ) ĊĠĠĠ Ġ} Ċ }