示例#1
0
        public void RefreshFilesystemInfo_Handles_Errors()
        {
            // arrange
            SetupFileSystem();
            ViewModel.Initialise();
            var testException = new Exception();

            A.CallTo(MockFileSystemHelper).Throws(testException);

            // act
            ViewModel.RefreshFileSystemInfo();

            // assert
            // writes the error to the logs
            A.CallTo(() => MockLogger.LogException(A <ILogger.MessageGenerator> .Ignored, testException)).MustHaveHappened(1, Times.Exactly);
            // writes the error to crshlytics
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustHaveHappened(1, Times.Exactly);
        }
        public async Task DownloadAllPodcastsWithoutNetworkCheck_HandlesException()
        {
            // arrange
            SetupMockControlFileFor2Podcasts();
            SetupEpisodesFor2Podcasts();
            ViewModel.Initialise();
            ViewModel.FindEpisodesToDownload();
            var testException = new Exception("TEST EXCEPTION");

            A.CallTo(() => MockTaskPool.RunAllTasks(A <int> .Ignored, A <ITask[]> .Ignored)).Throws(testException);

            // act
            await ViewModel.DownloadAllPodcastsWithoutNetworkCheck().ConfigureAwait(false);

            // assert
            Assert.AreEqual(1, ObservedResults.StartDownloadingCount, "start count");
            Assert.AreEqual(1, ObservedResults.EndDownloadingCount, "end count");
            A.CallTo(() => MockCrashReporter.LogNonFatalException(testException)).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockLogger.LogException(A <ILogger.MessageGenerator> .Ignored, testException)).MustHaveHappened(1, Times.Exactly);
            Assert.AreEqual("TEST EXCEPTION", ObservedResults.LastDisplayMessage);
        }
示例#3
0
        public void RefreshFilesystemInfo_Adds_DriveInfo_Before_An_Error()
        {
            // arrange
            SetupFileSystem();
            ViewModel.Initialise();
            // throw processing the second item
            var testException = new Exception();

            A.CallTo(() => MockFileSystemHelper.GetAvailableFileSystemSizeInBytes(PATH2)).Throws(testException);

            // act
            ViewModel.RefreshFileSystemInfo();

            // assert
            // writes the error to the logs
            A.CallTo(() => MockLogger.LogException(A <ILogger.MessageGenerator> .Ignored, testException)).MustHaveHappened(1, Times.Exactly);
            // writes the error to crshlytics
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustHaveHappened(1, Times.Exactly);

            // file 1
            A.CallToSet(() => MockDriveVolumeInfoView.Title).To(() => PATH1).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.SetSpace(100, 200, "100", "MB", "200", "MB")).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockDriveVolumeInfoView.GetView()).MustHaveHappened(1, Times.Exactly);
        }