Search in sources :

Example 1 with TasksRepository

use of com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository in project todo-mvp-rxjava by albertizzy.

the class StatisticsScreenTest method intentWithStubbedTaskId.

/**
 * Setup your test fixture with a fake task id. The {@link TaskDetailActivity} is started with
 * a particular task id, which is then loaded from the service API.
 *
 * <p>
 * Note that this test runs hermetically and is fully isolated using a fake implementation of
 * the service API. This is a great way to make your tests more reliable and faster at the same
 * time, since they are isolated from any outside dependencies.
 */
@Before
public void intentWithStubbedTaskId() {
    // Given some tasks
    TasksRepository.destroyInstance();
    TasksRepository repository = Injection.provideTasksRepository(InstrumentationRegistry.getContext());
    repository.saveTask(new Task("Title1", "", false));
    repository.saveTask(new Task("Title2", "", true));
    // Lazily start the Activity from the ActivityTestRule
    Intent startIntent = new Intent();
    mStatisticsActivityTestRule.launchActivity(startIntent);
}
Also used : TasksRepository(com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository) Task(com.example.android.architecture.blueprints.todoapp.data.Task) Intent(android.content.Intent) Before(org.junit.Before)

Aggregations

Intent (android.content.Intent)1 Task (com.example.android.architecture.blueprints.todoapp.data.Task)1 TasksRepository (com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository)1 Before (org.junit.Before)1