@Test
public void getTasks_repositoryCachesAfterFirstSubscription_whenTasksAvailableInLocalStorage() {

    // Given that the local data source has data available
    setTasksAvailable(mTasksLocalDataSource, TASKS);
    // And the remote data source does not have any data available
    setTasksNotAvailable(mTasksRemoteDataSource);
    // When two subscriptions are set
    TestSubscriber<List<Task>> testSubscriber1 = new TestSubscriber<>();
    mTasksRepository.getTasks().subscribe(testSubscriber1);
    TestSubscriber<List<Task>> testSubscriber2 = new TestSubscriber<>();
    mTasksRepository.getTasks().subscribe(testSubscriber2);
    // Then tasks were only requested once from remote and local sources
    Mockito.verify(mTasksRemoteDataSource).getTasks();
    Mockito.verify(mTasksLocalDataSource).getTasks();
    //
    assertFalse(mTasksRepository.mCacheIsDirty);
    testSubscriber1.assertValue(TASKS);
    testSubscriber2.assertValue(TASKS);
}