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);
        }
        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);
        }