/// <summary>
        ///     Creates a new instance of this class with the given service dependencies.
        /// </summary>
        /// <param name="dependencies">Parameter object containing dependencies for this service.</param>
        public ExecutionStrategyFactory(ExecutionStrategyDependencies dependencies)
        {
            Check.NotNull(dependencies, nameof(dependencies));

            Dependencies = dependencies;
            _instance    = new NonRetryingExecutionStrategy(Dependencies);
        }
        private void Execute_doesnt_retry(Action<IExecutionStrategy, Func<int>> execute)
        {
            var executionStrategy = new NonRetryingExecutionStrategy();
            var executionCount = 0;
            Assert.Throws<TimeoutException>(
                () =>
                execute(executionStrategy,
                    () =>
                    {
                        executionCount++;
                        throw new TimeoutException();
                    }));

            Assert.Equal(1, executionCount);
        }
        private void ExecuteAsync_doesnt_retry(Func<IExecutionStrategy, Func<Task<int>>, Task> executeAsync)
        {
            var executionStrategy = new NonRetryingExecutionStrategy();
            var executionCount = 0;
            Assert.Throws<TimeoutException>(
                () =>
                ExceptionHelpers.UnwrapAggregateExceptions(
                    () =>
                    executeAsync(executionStrategy,
                        () =>
                        {
                            executionCount++;
                            throw new TimeoutException();
                        }).Wait()));

            Assert.Equal(1, executionCount);
        }
Esempio n. 4
0
 /// <summary>
 ///     Creates a new instance of this class with the given service dependencies.
 /// </summary>
 /// <param name="dependencies">Parameter object containing dependencies for this service.</param>
 public ExecutionStrategyFactory(ExecutionStrategyDependencies dependencies)
 {
     Dependencies = dependencies;
     _instance    = new NonRetryingExecutionStrategy(Dependencies);
 }