package Ġcom . sum mit . core . db . dao Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . sum mit . core . db . App DB Ċ import Ġcom . sum mit . core . network . model . depart amento . Ub ic acion Model Ċ import Ġcom . sum mit . test _ utils . li ved ata . getValue Ċ import Ġcom . sum mit . test _ utils . ro bo . Test Ro bo lectric Ċ import Ġjunit . framework . Assert . assertEquals Ċ import Ġjunit . framework . Assert . assertNot Same Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit .* ĊĊ Ċ class ĠU bic acion Model Dao Test : ĠTest Ro bo lectric () Ġ Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdatabase : ĠApp DB ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġ ubic acion Model Dao : ĠU bic acion Model Dao ĊĠĠĠ Ġprivate Ġval Ġfake Ub ication Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠU bic acion Model (" L ima "," San ĠM ig uel ", 0 ), ĊĠĠĠĠĠĠĠ ĠU bic acion Model (" Are quip a "," Jo ya ", 1 ), ĊĠĠĠĠĠĠĠ ĠU bic acion Model (" P uno "," P uno ", 1 ), ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontext Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĠĠĠĠĠĠĠ Ġdatabase Ġ= ĠRoom ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. in Memory Database Builder ( context , ĠApp DB :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. allow MainThread Queries () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao Ġ= Ġdatabase . ubic acion Model Dao () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġdestroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . close () ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` obtain Ġ ubic ation , Ġshould Ġreturn Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( getValue ( characters )== null ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` insert Ġ ubic ation Ġand Ġobtain Ġ ubic ation , Ġshould Ġreturn Ġdata Ġand Ġequals Ġdata `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . insert Ub ic acion Model ( fake Ub ication [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠassertEquals ( fake Ub ication [ 0 ], ĠgetValue ( characters )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` insert Ġ ubic ation Ġand Ġobtain Ġ ubic ation , Ġshould Ġreturn Ġdata Ġnot Ġequals `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . insert Ub ic acion Model ( fake Ub ication [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ Ġassert Not Same ( fake Ub ication [ 1 ], ĠgetValue ( characters )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` insert Ġ ubic ation Ġand Ġdelete Ġ ubic ation , Ġshould Ġreturn Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . insert Ub ic acion Model ( fake Ub ication [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( getValue ( characters )!= null ) ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . delete Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( getValue ( characters )== null ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` insert Ġ ubic ation Ġand Ġupdate Ġ ubic ation , Ġshould Ġreturn Ġnot Ġequals Ġvalue `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . insert Ub ic acion Model ( fake Ub ication [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġ ubic ation Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠassertEquals ( fake Ub ication [ 0 ], ĠgetValue ( ubic ation )) ĊĠĠĠĠĠĠĠ Ġval Ġdata = fake Ub ication [ 0 ] ĊĠĠĠĠĠĠĠ Ġdata . depart amento =" Ac ap ul co " ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . update Ub ic acion Model ( data ) ĊĠĠĠĠĠĠĠ Ġval Ġ ubic ation Updated Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model () ĊĠĠĠĠĠĠĠ ĠassertEquals ( data , ĠgetValue ( ubic ation Updated )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` select Ġdata Ġwithout Ġli ved ata , Ġshould Ġreturn Ġvalue `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ ubic acion Model Dao . insert Ub ic acion Model ( fake Ub ication [ 0 ]) ĊĠĠĠĠĠĠĠ Ġval Ġ ubic ation Ġ= Ġ ubic acion Model Dao . select Ub ic acion Model Static () ĊĠĠĠĠĠĠĠ ĠassertEquals ( fake Ub ication [ 0 ], Ġ ubic ation ) ĊĊĠĠĠ Ġ} Ċ Ċ }