@Before public void setup() { ((TestApplicationComponent) RacquetApplication.getApplication().getApplicationComponent()) .inject(this); List<Match> matches = ModelBuilder.getMatches(5, "player1", "player2"); adapter = new MatchesAdapter(matches); }
@Test public void onViewCreated_shouldPopulateAdapter() { Clubs clubs = ModelBuilder.getClubs(4, "Club Name"); mockRestService.addResponse(clubs, true); SupportFragmentTestUtil.startFragment(fragment); assertThat(fragment.adapter.getItemCount()).isEqualTo(4); }
@Test public void onFetchedMatchesEvent_shouldPopulatePlayersSet() { List<Match> matches = ModelBuilder.getMatches(10, "player1", "player2"); bus.post(new FetchedMatchesEvent(matches)); assertThat(activity.players).hasSize(2); }
@Before public void setup() { ((TestApplicationComponent) RacquetApplication.getApplication().getApplicationComponent()) .inject(this); Club club = ModelBuilder.getClub(1, "My Club"); Intent intent = ClubActivity.getIntent(RuntimeEnvironment.application, club); ActivityController<ClubActivity> activityController = ActivityController.of(Robolectric.getShadowsAdapter(), ClubActivity.class); activity = activityController.withIntent(intent).setup().get(); }
@Test public void pullToRefresh_refetchesClubs() { SupportFragmentTestUtil.startFragment(fragment); assertThat(fragment.adapter.getItemCount()).isEqualTo(0); Clubs clubs = ModelBuilder.getClubs(4, "Club Name"); mockRestService.addResponse(clubs, true); fragment.onRefresh(); assertThat(fragment.adapter.getItemCount()).isEqualTo(4); }
@Test public void addMatch_updatesDataModel() { assertThat(adapter.getItemCount()).isEqualTo(5); adapter.addMatch(ModelBuilder.getMatch("1", "2")); assertThat(adapter.getItemCount()).isEqualTo(6); }