public void SaveChangesErrorDetectionStrategyDataServiceClientExceptionTest() { HttpStatusCode[] allHttpStatusCodeValues = (HttpStatusCode[])Enum.GetValues(typeof(HttpStatusCode)); SaveChangesErrorDetectionStrategy strategy = new SaveChangesErrorDetectionStrategy(); 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 SaveChangesErrorDetectionStrategyWebExceptionTest() { WebExceptionStatus[] allWebExceptionStatusValues = (WebExceptionStatus[])Enum.GetValues(typeof(WebExceptionStatus)); SaveChangesErrorDetectionStrategy strategy = new SaveChangesErrorDetectionStrategy(); 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()); } } }