public void ShouldCompleteOperation(IBackgroundOperation backgroundOperation) { _scheduledOperations.AddToBack(backgroundOperation); ExecuteCount = 0; while (ExecuteCount < MaxExecuteCount) { ++ExecuteCount; if (_scheduledOperations[0].Execute(MockSubOperationScheduler.Object).IsComplete) { var disposableOperation = _scheduledOperations.RemoveFromFront() as IDisposable; if (disposableOperation != null) { disposableOperation.Dispose(); } if (_scheduledOperations.Count == 0) { return; } } } throw new ShouldAssertException($"Operation of type {backgroundOperation.GetType().Name} should have completed within {MaxExecuteCount} executions, but didn't"); }
public void UnregisterOperation(IBackgroundOperation operation) { var operationViewModel = this.Operations.FirstOrDefault(op => op.Contains(operation)); if (operationViewModel != null) { ApplicationServices.ExecuteOnUIThread(() => this.Operations.Remove(operationViewModel)); } }
internal OperationAndData(IBackgroundOperation <T> operation, T data, IBackgroundCallback callback, ErrorCallback <T> errorCallback, Object context) { this.operation = operation; this.data = data; this.callback = callback; this.errorCallback = errorCallback; this.context = context; reset(); }
public void ShouldCompleteOperationIn(IBackgroundOperation backgroundOperation, int expectedExecuteCount) { ShouldCompleteOperation(backgroundOperation); if (ExecuteCount != expectedExecuteCount) { throw new ShouldAssertException($"Operation of type {backgroundOperation.GetType().Name} should have completed in {expectedExecuteCount} executions, but instead completed in {ExecuteCount}"); } }
public void Registry(IBackgroundOperation operation) { LockQueue(); _inQueue.Add(operation); if (!_isDispatcherRuned) { _isDispatcherRuned = true; Task.Run(RunDispatcher); } UnLockQueue(); }
public bool Contains(IBackgroundOperation operation) { return(this.Operation.Equals(operation)); }
public BackgroundOperationViewModel(IBackgroundOperation operation) { Operation = operation; Operation.PropertyChanged += Operation_PropertyChanged; }
public void RegisterOperation(IBackgroundOperation operation) { ApplicationServices.ExecuteOnUIThread(() => Operations.Add(new BackgroundOperationViewModel(operation))); }
public void ScheduleOperation(IBackgroundOperation operation) => _scheduledOperations.Enqueue(operation);
public static void ShouldRunToCompletion(this IBackgroundOperation backgroundOperation) => backgroundOperation.ShouldRunToCompletion(new FakeBackgroundWorker());
public static void ShouldRunToCompletionIn(this IBackgroundOperation backgroundOperation, FakeBackgroundWorker backgroundWorker, int expectedExecuteCount) => backgroundWorker.ShouldCompleteOperationIn(backgroundOperation, expectedExecuteCount);
public static void ShouldRunToCompletionIn(this IBackgroundOperation backgroundOperation, int expectedExecuteCount = 100) => backgroundOperation.ShouldRunToCompletionIn(new FakeBackgroundWorker(), expectedExecuteCount);
public static void ShouldRunToCompletion(this IBackgroundOperation backgroundOperation, FakeBackgroundWorker backgroundWorker) => backgroundWorker.ShouldCompleteOperation(backgroundOperation);