package Ġorg . buffer . android . boilerplate . cache . dao Ċ Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġorg . buffer . android . boilerplate . cache . db . Buffer o os Database Ċ import Ġorg . buffer . android . boilerplate . cache . test . factory . Buffer oo Factory Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ open Ġclass ĠCached Buffer oo Dao Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbuffer o os Database : ĠBuffer o os Database ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġbuffer o os Database Ġ= ĠRoom . in Memory Database Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠApplication Provider . getApplicationContext (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBuffer o os Database :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. allow MainThread Queries () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġclose Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġbuffer o os Database . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Buffer o os S aves Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcached Buffer oo Ġ= ĠBuffer oo Factory . make Cached Buffer oo () ĊĠĠĠĠĠĠĠ Ġbuffer o os Database . cached Buffer oo Dao (). insert Buffer oo ( cached Buffer oo ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbuffer o os Ġ= Ġbuffer o os Database . cached Buffer oo Dao (). get Buffer o os () ĊĠĠĠĠĠĠĠ Ġassert ( buffer o os . isNotEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Buffer o os Retrie ves Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcached Buffer o os Ġ= ĠBuffer oo Factory . make Cached Buffer oo List ( 5 ) ĊĊĠĠĠĠĠĠĠ Ġcached Buffer o os . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuffer o os Database . cached Buffer oo Dao (). insert Buffer oo ( it ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġretrieved Buffer o os Ġ= Ġbuffer o os Database . cached Buffer oo Dao (). get Buffer o os () ĊĠĠĠĠĠĠĠ Ġassert ( retrie ved Buffer o os Ġ== Ġcached Buffer o os . sorted With ( compare By ({ Ġit . id Ġ}, Ġ{ Ġit . id Ġ} ))) ĊĠĠĠ Ġ} Ċ Ċ }