Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
factor AppPresenter tests to proper mock order
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Apr 18, 2012
1 parent 8f16db3 commit 0e22850
Showing 1 changed file with 7 additions and 20 deletions.
Expand Up @@ -172,48 +172,35 @@ public void testPerformsRequiredActionsOnBind()

public void testShowsNotificationEvents()
{
replayAllMocks();
appPresenter.bind();
verifyAllMocks();

reset(mockDisplay);
String testMessage = "test notification message";
mockDisplay.setNotificationMessage(testMessage, Severity.Warning);
expectLastCall().once();
expect(mockDisplay.getDismissVisibility()).andReturn(mockDismissVisibility).anyTimes();
replay(mockDisplay);

reset(mockDismissVisibility);
mockDismissVisibility.setVisible(true);
expectLastCall().once();
replay(mockDismissVisibility);

replayAllMocks();

appPresenter.bind();
NotificationEvent notification = new NotificationEvent(Severity.Warning, testMessage);
capturedNotificationEventHandler.getValue().onNotification(notification);

verify(mockDisplay);
verify(mockDismissVisibility);
verifyAllMocks();
}

public void testShowsUpdatedProjectStats()
{
replayAllMocks();
appPresenter.bind();
verifyAllMocks();

reset(mockDisplay);
Capture<TranslationStats> capturedTranslationStats = new Capture<TranslationStats>();
mockDisplay.setStats(and(capture(capturedTranslationStats), isA(TranslationStats.class)));
expectLastCall().once();
replay(mockDisplay);

replayAllMocks();

appPresenter.bind();
TranslationStats testStats = new TranslationStats(new TransUnitCount(6, 5, 4), new TransUnitWords(3, 2, 1));
ProjectStatsUpdatedEvent event = new ProjectStatsUpdatedEvent(testStats);
capturedProjectStatsUpdatedEventHandler.getValue().onProjectStatsRetrieved(event);

verify(mockDisplay);

verifyAllMocks();
assertThat(capturedTranslationStats.getValue(), is(equalTo(testStats)));
}

Expand Down

0 comments on commit 0e22850

Please sign in to comment.