示例#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");
        }
示例#2
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}");
            }
        }