Exemplo n.º 1
0
        private bool ShouldRetry(RetryPolicy retryPolicy, Context context, OTSException exception)
        {
            if (retryPolicy.MaxRetryTimeReached(context, exception))
            {
                return(false);
            }

            if (retryPolicy.CanRetry(context, exception))
            {
                return(true);
            }

            return(false);
        }
        void TestRetryCondition(int[][] retryConditionTable, HttpStatusCode httpCode)
        {
            for (int i = 0; i < apiNames.Count(); i++)
            {
                for (int j = 0; j < errors.Count(); j++)
                {
                    var apiName      = "/" + apiNames[i];
                    var errorCode    = errors[j][0];
                    var errorMessage = errors[j][1];
                    var expect       = retryConditionTable[j][i] == 1;

                    var exception = new OTSServerException(apiName, httpCode, errorCode, errorMessage);
                    var context   = new Context();
                    context.APIName = apiName;

                    Assert.AreEqual(expect, retryPolicy.CanRetry(context, exception),
                                    "Retry Condition Not Match: API Name {0}, Error Code: {1}",
                                    apiName, errorCode);
                }
            }
        }