title: Mock Room database for Unit tests
body: <p>I'm trying to make some Unit tests for my business logic.</p>
  
  <p>Data is read and written to Room database, so the logic depends on what's inside my database.</p>
  
  <p>I can easily <code>buildInMemoryDatabase</code> and test all the logic, but using Instrumental tests which are <strong>slow and require a device to be connected</strong>.</p>
  
  <p>I want to run Unit tests only where I replace my <code>RoomRepository</code> with some other implementation of <code>Repository</code> interface</p>
  
  <pre><code>class RoomRepository(
      private val database: RoomDatabase //actual room database
  ): Repository {
  
      override fun getFooByType(type: Int): Maybe&lt;List&lt;Item&gt;&gt; {
          return database.fooDao()
              .getFooByType(type)
              .map { names -&gt;
                  names.map { name -&gt; Item(name) }
              }
              .subscribeOn(Schedulers.io())
      }
  }
  </code></pre>
  
  <p>Maybe there is a way to run Room sqlite on host machine?</p>
  
  <p>Maybe there is another solution?</p>