package Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . use case . search history Ċ Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . data . Dummy Data Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . executor . Test Post Execution Thread Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . f akes . Fake Search History Repository Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . model . Character Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . Test Ċ Ċ class ĠSave Search Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġsearch History Repository Ġ= ĠFake Search History Repository () ĊĠĠĠ Ġprivate Ġval Ġsave Search Ġ= ĠSave Search ( search History Repository , ĠTest Post Execution Thread ()) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat Ġsave Search Ġcaches Ġthe Ġsearch `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Ġ= ĠDummy Data . character ĊĠĠĠĠĠĠĠ Ġsave Search ( character ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠCharacter Ġ= Ġsearch History Repository . get Search History (). first (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( character ). isEqualTo ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat Ġsave Search Ġreplaces Ġa Ġcharacter Ġif Ġit Ġis Ġalready Ġsaved `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġname Ġ= Ġ" Mart in " ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Ġ= ĠDummy Data . character ĊĠĠĠĠĠĠĠ Ġval Ġcharacter 2 : ĠCharacter Ġ= Ġcharacter . copy ( name Ġ= Ġname ) ĊĠĠĠĠĠĠĠ Ġsave Search ( character ) ĊĠĠĠĠĠĠĠ Ġsave Search ( character 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠCharacter Ġ= Ġsearch History Repository . get Search History (). first (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( character ). isNot EqualTo ( result ) ĊĠĠĠĠĠĠĠ ĠassertThat ( character 2 . name ). isEqualTo ( name ) ĊĠĠĠ Ġ} Ċ } Ċ