public void TestThrottlingWithRetryAfterHeader() { try { HttpResponseMessage responseMessage = new HttpResponseMessage(HttpStatusCode.ServiceUnavailable); responseMessage.Headers.RetryAfter = new RetryConditionHeaderValue(TimeSpan.FromSeconds(4)); this.TestThrottlingBehaviorWithCustomStatusCode( HttpStatusCode.ServiceUnavailable, responseMessage); } catch (AggregateException e) { CallThrottledException throttledException = (CallThrottledException)e.InnerException; Assert.IsNotNull(throttledException); Assert.AreEqual( 3, throttledException.RetryCount); // 3 * 4 seconds retrieved from Retry-After Assert.AreEqual( 12, throttledException.TotalDelayApplied); throw; } }
public void TestThrottling503Behavior() { try { this.TestThrottlingBehaviorWithCustomStatusCode(HttpStatusCode.ServiceUnavailable); Assert.Fail("We shouldn't be here..."); } catch (AggregateException e) { CallThrottledException throttledException = (CallThrottledException)e.InnerException; Assert.IsNotNull(throttledException); Assert.AreEqual( 3, throttledException.RetryCount); Assert.AreEqual( 6, throttledException.TotalDelayApplied); throw; } }