Skip to content

Instantly share code, notes, and snippets.

@kmdupr33
Last active August 29, 2015 14:20
Show Gist options
  • Save kmdupr33/472d6cd32f935475773d to your computer and use it in GitHub Desktop.
Save kmdupr33/472d6cd32f935475773d to your computer and use it in GitHub Desktop.
Showing a second pass at writing a unit test for onStop() this time with more control over pre-act state
public void testShouldLaunchAddSessionService() {
//Arrange
SessionDetailViewTranslator sessionDetailViewTranslator = mock(SessionDetailViewTranslator.class);
Session session = new Session();
session.startTimestamp = "1431081943";
SessionRepositoryManager repositoryManager = new MockSessionRepositoryManager(session);
ServiceStarter serviceStarter = mock(ServiceStarter.class);
long calendarId = 0;
SessionDetailViewPresenter sessionDetailViewPresenter = new SessionDetailViewPresenter(sessionDetailViewTranslator,
repositoryManager,
serviceStarter,
calendarId);
sessionDetailViewPresenter.onViewCreated(null);
//Act
sessionDetailViewPresenter.onViewStopped();
//Assert
verify(serviceStarter).startAddCalendarSessionService(anyLong(), any(CalendarSession.class));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment