Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public void UnregisterOperation(IBackgroundOperation operation)
        {
            var operationViewModel = this.Operations.FirstOrDefault(op => op.Contains(operation));

            if (operationViewModel != null)
            {
                ApplicationServices.ExecuteOnUIThread(() => this.Operations.Remove(operationViewModel));
            }
        }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
        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}");
            }
        }
Ejemplo n.º 5
0
        public void Registry(IBackgroundOperation operation)
        {
            LockQueue();
            _inQueue.Add(operation);

            if (!_isDispatcherRuned)
            {
                _isDispatcherRuned = true;
                Task.Run(RunDispatcher);
            }
            UnLockQueue();
        }
Ejemplo n.º 6
0
 public bool Contains(IBackgroundOperation operation)
 {
     return(this.Operation.Equals(operation));
 }
Ejemplo n.º 7
0
 public BackgroundOperationViewModel(IBackgroundOperation operation)
 {
     Operation = operation;
     Operation.PropertyChanged += Operation_PropertyChanged;
 }
Ejemplo n.º 8
0
 public void RegisterOperation(IBackgroundOperation operation)
 {
     ApplicationServices.ExecuteOnUIThread(() => Operations.Add(new BackgroundOperationViewModel(operation)));
 }
Ejemplo n.º 9
0
 public void ScheduleOperation(IBackgroundOperation operation)
 => _scheduledOperations.Enqueue(operation);
Ejemplo n.º 10
0
 public static void ShouldRunToCompletion(this IBackgroundOperation backgroundOperation)
 => backgroundOperation.ShouldRunToCompletion(new FakeBackgroundWorker());
Ejemplo n.º 11
0
 public static void ShouldRunToCompletionIn(this IBackgroundOperation backgroundOperation, FakeBackgroundWorker backgroundWorker, int expectedExecuteCount)
 => backgroundWorker.ShouldCompleteOperationIn(backgroundOperation, expectedExecuteCount);
Ejemplo n.º 12
0
 public static void ShouldRunToCompletionIn(this IBackgroundOperation backgroundOperation, int expectedExecuteCount = 100)
 => backgroundOperation.ShouldRunToCompletionIn(new FakeBackgroundWorker(), expectedExecuteCount);
Ejemplo n.º 13
0
 public static void ShouldRunToCompletion(this IBackgroundOperation backgroundOperation, FakeBackgroundWorker backgroundWorker)
 => backgroundWorker.ShouldCompleteOperation(backgroundOperation);