package Ġcom . m re ig osa . mar vel app . data . sources . local . datasource Ċ Ċ import ĠMock DataProvider Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . m re ig osa . mar vel app . data . sources . local . database . Mar vel Database Ċ import Ġcom . m re ig osa . mar vel app . data . sources . local . mapper . Mar vel Character Local Entity Mapper Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠMar vel Local DataSource Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsut : ĠMar vel Local DataSource Impl ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdatabase : ĠMar vel Database ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase Ġ= ĠRoom . in Memory Database Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠApplication Provider . getApplicationContext (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMar vel Database :: class . java ĊĠĠĠĠĠĠĠ Ġ). build () ĊĊĠĠĠĠĠĠĠ Ġsut Ġ= ĠMar vel Local DataSource Impl ( database , ĠMar vel Character Local Entity Mapper ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven _ characters _ in _ database _ return _ them () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdatabase Entities Ġ= Ġgiven Character Entities () ĊĠĠĠĠĠĠĠ Ġdatabase . character Dao (). insert ( database Entities ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġsut . get Characters ( 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( characters . isEmpty ()). isFalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven _ no _ characters _ in _ database _ return _ empty _ list () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= Ġsut . get Characters ( 0 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( characters . isEmpty ()). isTrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcharacters _ can _ be _ saved _ into _ database () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacters Ġ= ĠMock DataProvider . given Mar vel Character Entity List () ĊĊĠĠĠĠĠĠĠ Ġsut . save Characters ( characters ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdb Result Ġ= Ġdatabase . character Dao (). get Characters ( 0 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( db Result . isEmpty ()). isFalse ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgiven Character Entities () Ġ= ĠMock DataProvider . given Mar vel Character Local Entity List () Ċ }