public void Report_SingleProgress() { var progress = new Mock <IProgress <int> >(); var aggregate = AggregateProgress.Create(progress.Object); aggregate.Report(1); aggregate.Report(2); progress.Verify(mock => mock.Report(1), Times.Once); progress.Verify(mock => mock.Report(2), Times.Once); progress.VerifyNoOtherCalls(); }
/// <summary> /// Load the query synchronously. <see cref="Cancellation"/> is used for cancellation /// token, <see cref="Progress"/> is used for reporting progress. /// </summary> /// <remarks> /// Found entities are added to a waiting queue. Use <see cref="Update"/> to get all /// entities loaded so far. /// </remarks> /// <seealso cref="RunAsync"/> public void Run() { var progress = AggregateProgress.Create( Progress, new FolderQueryProgress(_fileWatcher)); var options = new ExecutionOptions { CancellationToken = Cancellation.Token, Progress = progress }; foreach (var entity in Query.Execute(options)) { var thumbnail = _thumbnailFactory.Create(entity, Cancellation.Token); EnqueueRequest(new AddRequest(new EntityView(entity, thumbnail))); } }
public void Report_MultipleProgressObjects() { var progress = new[] { new Mock <IProgress <int> >(), new Mock <IProgress <int> >(), new Mock <IProgress <int> >(), }; var aggregate = AggregateProgress.Create(progress.Select(item => item.Object).ToArray()); aggregate.Report(1); aggregate.Report(2); foreach (var item in progress) { item.Verify(mock => mock.Report(1), Times.Once); item.Verify(mock => mock.Report(2), Times.Once); item.VerifyNoOtherCalls(); } }