/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 1 . ĠR yan ĠW ong Ġ( hello @ ry an w ong . co . uk ) Ċ Ġ* Ċ Ġ*/ Ċ Ċ package Ġcom . example . android . polit ical prepared ness . di Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . room . Room Ċ import Ġcom . example . android . polit ical prepared ness . data . database . E lection Database Ċ import Ġdagger . Module Ċ import Ġdagger . Provides Ċ import Ġdagger . h ilt . android . qual ifiers . ApplicationContext Ċ import Ġdagger . h ilt . components . Singleton Component Ċ import Ġdagger . h ilt . testing . Test Install In Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Module Ċ @ Test Install In ( ĊĠĠĠ Ġcomponents Ġ= Ġ[ Singleton Component :: class ], ĊĠĠĠ Ġreplaces Ġ= Ġ[ Database Modules :: class ] Ċ ) Ċ object ĠFake Database Modules Ġ{ ĊĊĠĠĠ Ġ// ĠUsing Ġan Ġin - memory Ġdatabase Ġfor Ġtesting , Ġbecause Ġit Ġdoesn 't Ġsurv ive Ġk illing Ġthe Ġprocess . ĊĠĠĠ Ġ@ Provides ĊĠĠĠ Ġ@ Singleton ĊĠĠĠ Ġfun Ġprovide Database (@ ApplicationContext Ġapp Context : ĠContext ): ĠE lection Database Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠRoom . in Memory Database Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Context . application Context , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠE lection Database :: class . java ĊĠĠĠĠĠĠĠ Ġ). allow MainThread Queries (). build () ĊĠĠĠ Ġ} Ċ }