Exemple #1
0
 public void ThenWhereAValueIsReturnedItShouldBeTheOneReturnedByTheFinalOperationInvocationActionTypeAction(RetryActionType actionType)
 {
     switch (actionType)
     {
     case RetryActionType.Function:
     case RetryActionType.AsyncFunction:
         Assert.AreSame(this.lastObjectReturnedByFunction, this.retryResult);
         break;
     }
 }
Exemple #2
0
        public async Task WhenIInvokeTheOperationWithRetriableTypeActionPassingNoAdditionalArguments(RetryActionType actionType)
        {
            Action?               action        = null;
            Func <Task>?          asyncAction   = null;
            Func <Task <object> >?asyncFunction = null;

            if (this.function != null)
            {
                action      = () => this.function();
                asyncAction = () =>
                {
                    action();
                    return(Task.CompletedTask);
                };
                asyncFunction = () => Task.FromResult(this.function());
            }

            // This code is used when testing the case where different arguments are null, therefore the null forgiving operator is intentionally used
            // to accurately describe the intention of the test.
            switch (actionType)
            {
            case RetryActionType.Action:
                Retriable.Retry(action !);
                break;

            case RetryActionType.Function:
                this.retryResult = Retriable.Retry(this.function !);
                break;

            case RetryActionType.AsyncAction:
                await Retriable.RetryAsync(asyncAction !).ConfigureAwait(false);

                break;

            case RetryActionType.AsyncActionSpecifyingContinueContext:
                await Retriable.RetryAsync(asyncAction !, false).ConfigureAwait(false);

                break;

            case RetryActionType.AsyncFunction:
                this.retryResult = await Retriable.RetryAsync(asyncFunction !).ConfigureAwait(false);

                break;

            case RetryActionType.AsyncFunctionSpecifyingContinueContext:
                this.retryResult = await Retriable.RetryAsync(asyncFunction !, false).ConfigureAwait(false);

                break;

            default:
                throw new ArgumentException("Unknown action: " + actionType);
            }
        }
Exemple #3
0
 public async Task WhenIAttemptToInvokeTheActionWithRetriableTypePassingNoAdditionalArgumentsAsync(RetryActionType actionType)
 {
     try
     {
         await this.WhenIInvokeTheOperationWithRetriableTypeActionPassingNoAdditionalArguments(actionType).ConfigureAwait(false);
     }
     catch (Exception x)
     {
         this.exceptionThrownByRetry = x;
     }
 }