public void IntuitRetryPolicyConstructorTestWithNegativeRetryCount() { int retryCount = -1; TimeSpan initialInterval = TimeSpan.FromSeconds(1); TimeSpan increment = TimeSpan.FromSeconds(1); try { IntuitRetryPolicy target = new IntuitRetryPolicy(retryCount, initialInterval, increment); Assert.Fail(); } catch (ArgumentException) { } }
public void ExecuteActionTestWithNonRetryException() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); Action action = this.ThrowUnauthorizedAccessException; try { target.ExecuteAction(action); Assert.Fail(); } catch (UnauthorizedAccessException ex) { Console.WriteLine(@"Message: {0}", ex.Message); } }
public void IntuitRetryPolicyConstructorTestWitMaxBackoffNegative() { int retryCount = 1; TimeSpan minBackoff = TimeSpan.FromSeconds(1); TimeSpan maxBackoff = TimeSpan.FromSeconds(-1); TimeSpan deltaBackoff = TimeSpan.FromSeconds(1); try { IntuitRetryPolicy target = new IntuitRetryPolicy(retryCount, minBackoff, maxBackoff, deltaBackoff); Assert.Fail(); } catch (ArgumentException) { } }
public void ExecuteActionTestWithExtendedRetryException() { IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); target.ExtendedRetryException = new ExtendedRetryUnauthorizedAccessException(); Action action = this.ThrowUnauthorizedAccessException; try { target.ExecuteAction(action); Assert.Fail(); } catch (System.Exception ex) { Console.WriteLine(@"Message: {0}", ex.Message); } }
public void ExecuteActionAsyncTestWithFixedRetryArgumentException() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); Exception exception = null; try { target.ExecuteAction( ac => { // Invoke the begin method of the asynchronous call. this.BeginRequestForArgumentException(ac); }, ar => { // Invoke the end method of the asynchronous call. }, () => { // Action to perform if the asynchronous operation // succeeded. }, e => { // Action to perform if the asynchronous operation // failed after all the retries. exception = e; }); throw exception; } catch (RetryExceededException) { Assert.Fail(); } catch (System.Exception ex) { if (!(ex is ArgumentException)) { Assert.Fail(); } } }
public void ExecuteActionTestWithTimeoutException() { try { IntuitRetryPolicy target = new IntuitRetryPolicy(0, TimeSpan.FromSeconds(1)); target.ExecuteAction( () => { // Invoke the begin method of the asynchronous call. throw new TimeoutException(); }); Assert.Fail(); } catch (RetryExceededException) { } }
public void ExecuteActionAsyncTestWithFixedRetryExceededException() { retryCount = 1; Exception exception = null; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); try { target.ExecuteAction( ac => { // Invoke the begin method of the asynchronous call. this.BeginRequestForProtocolException(ac); }, ar => { // Invoke the end method of the asynchronous call. }, () => { // Action to perform if the asynchronous operation // succeeded. }, e => { // Action to perform if the asynchronous operation // failed after all the retries. exception = e; }); throw exception; } catch (RetryExceededException intuitRetryExceededException) { WebException webException = intuitRetryExceededException.InnerException as WebException; if (!((webException != null) && webException.Status == WebExceptionStatus.ProtocolError)) { Assert.Fail(); } } }
public void ExecuteActionTestWithFixedRetryExceededException() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); Action action = this.ThrowProtocolException; try { target.ExecuteAction(action); Assert.Fail(); } catch (RetryExceededException intuitRetryExceededException) { WebException webException = intuitRetryExceededException.InnerException as WebException; if (!((webException != null) && webException.Status == WebExceptionStatus.ProtocolError)) { Assert.Fail(); } } }
public void ExecuteActionAsyncTestWithExtendedRetryException() { IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); target.ExtendedRetryException = new ExtendedRetryUnauthorizedAccessException(); Exception exception = null; try { target.ExecuteAction( ac => { // Invoke the begin method of the asynchronous call. this.BeginRequestForUnauthorizedException(ac); }, ar => { // Invoke the end method of the asynchronous call. }, () => { // Action to perform if the asynchronous operation // succeeded. }, e => { // Action to perform if the asynchronous operation // failed after all the retries. exception = e; }); throw exception; } catch (System.Exception ex) { Console.WriteLine(@"Message: {0}", ex.Message); Assert.Fail(); } }
public void ExecuteActionAsyncTestWithExponentialBackoffRetryExceededException() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(1)); Exception exception = null; try { target.ExecuteAction( ac => { // Invoke the begin method of the asynchronous call. this.BeginRequestForProtocolException(ac); }, ar => { // Invoke the end method of the asynchronous call. }, () => { // Action to perform if the asynchronous operation // succeeded. }, e => { // Action to perform if the asynchronous operation // failed after all the retries. exception = e; }); throw exception; } catch (RetryExceededException ex) { Console.WriteLine(@"Message: {0}", ex.Message); Assert.Fail(); } }
public void ExecuteActionAsyncTestWithIncrementalRetry() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(3, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)); Exception exception = null; try { target.ExecuteAction( ac => { // Invoke the begin method of the asynchronous call. this.BeginRequestForProtocolException(ac); }, ar => { // Invoke the end method of the asynchronous call. }, () => { // Action to perform if the asynchronous operation // succeeded. }, e => { // Action to perform if the asynchronous operation // failed after all the retries. exception = e; }); throw exception; } catch (RetryExceededException) { } }
public void ExecuteActionTestWithFixedRetryArgumentException() { retryCount = 1; IntuitRetryPolicy target = new IntuitRetryPolicy(2, TimeSpan.FromSeconds(1)); Action action = this.ThrowArgumentException; try { target.ExecuteAction(action); Assert.Fail(); } catch (RetryExceededException) { Assert.Fail(); } catch (System.Exception ex) { if (!(ex is ArgumentException)) { Assert.Fail(); } } }
public void IntuitRetryPolicyConstructorTestForFixed() { int retryCount = 0; TimeSpan retryInterval = TimeSpan.FromSeconds(1); IntuitRetryPolicy target = new IntuitRetryPolicy(retryCount, retryInterval); }