TodoActivity extends Activity { TodoProvider getProvider() { return TodoActivity.this.dataProvider; }  @Override void onCreate(final Bundle bundle); static final String APP_ID; }
@Test public void should_add_new_task() throws Exception { final TodoActivity activity = Robolectric.buildActivity(TodoActivity.class).create().get(); activity.getProvider().addTask("Some task"); final List<String> tasks = activity.getProvider().findAll(); Assert.assertEquals(tasks.size(), 1); }
@Test public void should_find_tasks() throws Exception { final TodoActivity activity = Robolectric.buildActivity(TodoActivity.class).create().get(); activity.getProvider().addTask("Some task 1"); activity.getProvider().addTask("Some task 2"); activity.getProvider().addTask("Some task 3"); final List<String> tasks = activity.getProvider().findAll(); Assert.assertEquals(tasks.size(), 3); }
@Test public void should_remove_task() throws Exception { final TodoActivity activity = Robolectric.buildActivity(TodoActivity.class).create().get(); activity.getProvider().addTask("Some task"); activity.getProvider().deleteTask("Some task"); final List<String> tasks = activity.getProvider().findAll(); Assert.assertEquals(tasks.size(), 0); }