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()); } } }
public void SaveChangesErrorDetectionStrategyTestIOException() { var exception = new System.IO.IOException(); bool actual = new SaveChangesErrorDetectionStrategy().IsTransient(exception); Assert.IsFalse(actual); }
public void SaveChangesErrorDetectionStrategyTestSocketException() { var exception = new SocketException(); bool actual = new SaveChangesErrorDetectionStrategy().IsTransient(exception); Assert.IsTrue(actual); }
public void SaveChangesErrorDetectionStrategyTestDataServiceQueryException() { // Unfortunately this exception isn't easy to Mock with an actual error code so just // do a basic test var exception = new DataServiceQueryException("Simulated DataServiceQueryException"); bool actual = new SaveChangesErrorDetectionStrategy().IsTransient(exception); Assert.IsFalse(actual); }
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 SaveChangesErrorDetectionStrategyTestGeneralException() { bool actual = new SaveChangesErrorDetectionStrategy().IsTransient(new Exception()); Assert.IsFalse(actual); }