public void CancelAllJobsAndExit_Exits()
        {
            // arrange
            int taskStartCount = 0;

            SetupMockControlFileFor2Podcasts();
            SetupEpisodesFor2Podcasts();
            ViewModel.Initialise();
            ViewModel.FindEpisodesToDownload();

            // act
            A.CallTo(() => MockTaskPool.RunAllTasks(A <int> .Ignored, A <ITask[]> .Ignored))
            .Invokes(() =>
            {
                taskStartCount++;
                if (taskStartCount > 1)
                {
                    throw new Exception("Concurrent calls are not being trapped");
                }
                ViewModel.RequestExit();
                ViewModel.CancelAllJobsAndExit();
            });
            ViewModel.DownloadAllPodcastsWithoutNetworkCheck().Wait();

            // assert
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => MockTaskPool.CancelAllTasks()).MustHaveHappened(1, Times.Exactly);
            Assert.AreEqual(1, ObservedResults.ExitCount, "exit count");
        }
        public void CancelAllJobsAndExit_CancelsJobs()
        {
            // arrange
            SetupMockControlFileFor2Podcasts();
            SetupEpisodesFor2Podcasts();
            ViewModel.Initialise();
            ViewModel.FindEpisodesToDownload();
            ViewModel.RequestExit();

            // act
            ViewModel.CancelAllJobsAndExit();

            // assert
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => MockTaskPool.CancelAllTasks()).MustHaveHappened(1, Times.Exactly);
            Assert.AreEqual("cancelling", ObservedResults.LastDisplayMessage);
        }
        public void ProgressUpdate_ChecksFreeSpace()
        {
            // arrange
            SetupMockControlFileFor2Podcasts();
            SetupEpisodesFor2Podcasts();
            ViewModel.Initialise();
            ViewModel.FindEpisodesToDownload();

            SetupFireProgressEvent(EPISODE_1_ID, 9);

            // act
            ViewModel.DownloadAllPodcastsWithoutNetworkCheck().Wait();

            // assert
            A.CallTo(() => MockCrashReporter.LogNonFatalException(A <Exception> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => MockFileSystemHelper.GetAvailableFileSystemSizeInBytes(A <string> .Ignored)).MustHaveHappened(1, Times.Exactly);
            A.CallTo(() => MockTaskPool.CancelAllTasks()).MustNotHaveHappened();
        }