public void StatusUpdate_Exception() { // arrange SetupMockControlFileFor2Podcasts(); SetupEpisodesFor2Podcasts(); ViewModel.Initialise(); ViewModel.FindEpisodesToDownload(); var testException = new Exception("TEST EXCEPTION"); var syncItemMocker = SetupFireStatusEvent(EPISODE_1_ID, StatusUpdateLevel.Error, false, testException, "test exception"); Fake.ClearRecordedCalls(MockStatusAndProgressMessageStore); Fake.ClearRecordedCalls(MockAnalyticsEngine); // act ViewModel.DownloadAllPodcastsWithoutNetworkCheck().Wait(); // assert A.CallTo(() => MockCrashReporter.LogNonFatalException(testException)).MustHaveHappened(1, Times.Exactly); A.CallTo(() => MockStatusAndProgressMessageStore.StoreMessage( A <Guid> .That.Matches(g => g.ToString() == EPISODE_1_ID.ToString()), A <string> .That.Matches(s => s == "test exception"))) .MustHaveHappened(1, Times.Exactly); A.CallTo(() => MockStatusAndProgressMessageStore.StoreMessage( A <Guid> .That.Matches(g => g.ToString() == EPISODE_1_ID.ToString()), A <string> .That.Matches(s => s == "System.Exception: TEST EXCEPTION"))) .MustHaveHappened(1, Times.Exactly); Assert.AreEqual("test exception", ObservedResults.LastUpdateStatusMessage, "message"); Assert.AreEqual(syncItemMocker.GetMockedSyncItem(), ObservedResults.LastUpdateStatusItem, "item"); Assert.AreEqual(Status.Error, ObservedResults.LastUpdateStatus, "status"); A.CallTo(MockAnalyticsEngine).MustNotHaveHappened(); }
public void ProgressUpdate_UpdatesProgress_At_10() { // arrange SetupMockControlFileFor2Podcasts(); SetupEpisodesFor2Podcasts(); ViewModel.Initialise(); ViewModel.FindEpisodesToDownload(); var syncItemMocker = SetupFireProgressEvent(EPISODE_1_ID, 10); Fake.ClearRecordedCalls(MockStatusAndProgressMessageStore); // act ViewModel.DownloadAllPodcastsWithoutNetworkCheck().Wait(); // assert A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened(); A.CallTo(() => MockStatusAndProgressMessageStore.StoreMessage( A <Guid> .That.Matches(g => g.ToString() == EPISODE_1_ID.ToString()), A <string> .That.Matches(s => s == "EpisodeTitle (10 bytes of 100 bytes) 10%"))) .MustHaveHappened(1, Times.Exactly); Assert.AreEqual(10, ObservedResults.LastUpdatePercentage, "percentage"); Assert.AreEqual(syncItemMocker.GetMockedSyncItem(), ObservedResults.LastUpdatePercentageItem, "item"); }