private SyncItemMocker SetupFireStatusEvent(Guid id, StatusUpdateLevel level, bool complete, Exception ex, string message)
        {
            var syncItemMocker = new SyncItemMocker().ApplyId(id).ApplyEpisodeTitle("EpisodeTitle");
            EventHandler <StatusUpdateEventArgs> statusEventHandler = null;
            StatusUpdateEventArgs statusArgs =
                ex != null
                ? new StatusUpdateEventArgs(level, message, ex, complete, syncItemMocker.GetMockedSyncItem())
                : new StatusUpdateEventArgs(level, message, complete, syncItemMocker.GetMockedSyncItem());

            A.CallTo(() =>
                     MockSyncItemToEpisodeDownloaderTaskConverter.ConvertItemsToTasks
                     (
                         A <IList <ISyncItem> > .Ignored,
                         A <EventHandler <StatusUpdateEventArgs> > .Ignored,
                         A <EventHandler <ProgressEventArgs> > .Ignored
                     ))
            .ReturnsLazily((IList <ISyncItem> items, EventHandler <StatusUpdateEventArgs> statusEvent, EventHandler <ProgressEventArgs> progressEvent) =>
            {
                statusEventHandler = statusEvent;
                return(new IEpisodeDownloader[0]);
            });
            A.CallTo(() => MockTaskPool.RunAllTasks(A <int> .Ignored, A <ITask[]> .Ignored))
            .Invokes(() =>
            {
                statusEventHandler?.Invoke(this, statusArgs);
            });
            return(syncItemMocker);
        }
        protected void SetupEpisodesFor2Podcasts()
        {
            var syncItemMocker1 = new SyncItemMocker().ApplyId(EPISODE_1_ID).ApplyEpisodeTitle(EPISODE_1_TITLE);
            var syncItemMocker2 = new SyncItemMocker().ApplyId(EPISODE_2_ID).ApplyEpisodeTitle(EPISODE_2_TITLE);

            A.CallTo(() => MockPodcastEpisodeFinder.FindEpisodesToDownload(SOURCE_ROOT, RETRY_TIME, podcast1Mocker.GetMockedPodcastInfo(), DIAGS))
            .Returns(
                new List <ISyncItem>()
            {
                syncItemMocker1.GetMockedSyncItem(),
                syncItemMocker2.GetMockedSyncItem()
            }
                );


            var syncItemMocker3 = new SyncItemMocker().ApplyId(EPISODE_3_ID).ApplyEpisodeTitle(EPISODE_3_TITLE);
            var syncItemMocker4 = new SyncItemMocker().ApplyId(EPISODE_4_ID).ApplyEpisodeTitle(EPISODE_4_TITLE);
            var syncItemMocker5 = new SyncItemMocker().ApplyId(EPISODE_5_ID).ApplyEpisodeTitle(EPISODE_5_TITLE);

            A.CallTo(() => MockPodcastEpisodeFinder.FindEpisodesToDownload(SOURCE_ROOT, RETRY_TIME, podcast2Mocker.GetMockedPodcastInfo(), DIAGS))
            .Returns(
                new List <ISyncItem>()
            {
                syncItemMocker3.GetMockedSyncItem(),
                syncItemMocker4.GetMockedSyncItem(),
                syncItemMocker5.GetMockedSyncItem()
            }
                );
        }
        private SyncItemMocker SetupFireProgressEvent(Guid id, int percentage)
        {
            var syncItemMocker = new SyncItemMocker().ApplyId(id).ApplyEpisodeTitle("EpisodeTitle");
            EventHandler <ProgressEventArgs> progressEventHandler = null;
            ProgressEventArgs progressArgs = new ProgressEventArgs();

            A.CallTo(() =>
                     MockSyncItemToEpisodeDownloaderTaskConverter.ConvertItemsToTasks
                     (
                         A <IList <ISyncItem> > .Ignored,
                         A <EventHandler <StatusUpdateEventArgs> > .Ignored,
                         A <EventHandler <ProgressEventArgs> > .Ignored
                     ))
            .ReturnsLazily((IList <ISyncItem> items, EventHandler <StatusUpdateEventArgs> statusEvent, EventHandler <ProgressEventArgs> progressEvent) =>
            {
                progressEventHandler = progressEvent;
                return(new IEpisodeDownloader[0]);
            });
            A.CallTo(() => MockTaskPool.RunAllTasks(A <int> .Ignored, A <ITask[]> .Ignored))
            .Invokes(() =>
            {
                progressArgs.TotalItemsToProcess = 100;
                progressArgs.ItemsProcessed      = percentage;
                progressArgs.ProgressPercentage  = percentage;
                progressArgs.UserState           = syncItemMocker.GetMockedSyncItem();
                progressEventHandler?.Invoke(this, progressArgs);
            });
            return(syncItemMocker);
        }