Example #1
0
        public void QueryErrorDetectionStrategyWebExceptionTest()
        {
            WebExceptionStatus[] allWebExceptionStatusValues = (WebExceptionStatus[])Enum.GetValues(typeof(WebExceptionStatus));

            QueryErrorDetectionStrategy strategy = new QueryErrorDetectionStrategy();

            foreach (WebExceptionStatus status in allWebExceptionStatusValues)
            {
                if (status == WebExceptionStatus.ProtocolError)
                {
                    // This is covered in a separate test
                    continue;
                }

                WebException exception = new WebException("Simulated WebException with " + status.ToString(), status);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
            }
        }
Example #2
0
        public void QueryErrorDetectionStrategyDataServiceClientExceptionTest()
        {
            HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode));

            QueryErrorDetectionStrategy strategy = new QueryErrorDetectionStrategy();

            foreach (HttpStatusCode status in allHttpStatusCodeValues)
            {
                DataServiceClientException exception = GetMockedClientException(status);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
            }
        }