public void StorageTransientErrorDetectionStrategyDataServiceClientExceptionTestByErrorString()
        {
            List<String> allStorageErrorCodeStrings = GetAllStorageErrorStringConstants();

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (string errorString in allStorageErrorCodeStrings)
            {
                var innerException = new Exception(FormatErrorString(errorString));
                var exception = new DataServiceQueryException("Simulated DataServiceQueryException", innerException);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
            }
        }
        public void StorageTransientErrorDetectionStrategyDataServiceClientExceptionTestByStatusCode()
        {
            HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

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

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableHttpStatusCodes.Contains(status), status.ToString());
                }
            }
        }
        public void StorageTransientErrorDetectionStrategyWebExceptionTest()
        {
            WebExceptionStatus[] allWebExceptionStatusValues = (WebExceptionStatus[])Enum.GetValues(typeof(WebExceptionStatus));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            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(QueryErrorDetectionStrategyTest.SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
                else
                {
                    Assert.IsFalse(QueryErrorDetectionStrategyTest.SupportedRetryableWebExceptions.Contains(exception.Status), exception.Status.ToString());
                }
            }
        }
        public void StorageTransientErrorDetectionStrategyTestTimeoutException()
        {
            var exception = new TimeoutException();

            bool actual = new StorageTransientErrorDetectionStrategy().IsTransient(exception);

            Assert.IsTrue(actual);
        }
        public void StorageTransientErrorDetectionStrategyTestStorageException()
        {
            List<String> allStorageErrorCodeStrings = GetAllStorageErrorStringConstants();

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (string errorString in allStorageErrorCodeStrings)
            {
                var exception = GetSimulatedStorageTransientErrorDetectionStrategy(errorString);

                if (strategy.IsTransient(exception))
                {
                    Assert.IsTrue(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
                else
                {
                    Assert.IsFalse(SupportedRetryableStorageErrorStrings.Contains(errorString));
                }
            }
        }
        public void StorageTransientErrorDetectionStrategyTestGeneralException()
        {
            bool actual = new StorageTransientErrorDetectionStrategy().IsTransient(new Exception());

            Assert.IsFalse(actual);
        }
        public void StorageTransientErrorDetectionStrategyDataServiceTransportExceptionTest()
        {
            HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode));

            StorageTransientErrorDetectionStrategy strategy = new StorageTransientErrorDetectionStrategy();

            foreach (HttpStatusCode status in allHttpStatusCodeValues)
            {
                DataServiceTransportException exception = QueryErrorDetectionStrategyTest.GetMockedTransportException(status);

                Assert.IsFalse(strategy.IsTransient(exception));
            }
        }