public void NoRetryAfterHeader_RetryAfterSecondsIsSetToTheDefaultOfNull() { var response = CreateResponse(HttpStatusCode.Forbidden); var abuseException = new AbuseException(response); Assert.False(abuseException.RetryAfterSeconds.HasValue); }
public void HasDefaultMessage() { var response = new Response(HttpStatusCode.Forbidden, null, new Dictionary <string, string>(), "application/json"); var abuseException = new AbuseException(response); Assert.Equal("Request Forbidden - Abuse Detection", abuseException.Message); }
public void HasDefaultMessage() { var response = CreateResponse(HttpStatusCode.Forbidden); var abuseException = new AbuseException(response); Assert.Equal("Request Forbidden - Abuse Detection", abuseException.Message); }
public void NoRetryAfterHeader_RetryAfterSecondsIsSetToTheDefaultOfNull() { var headerDictionary = new Dictionary <string, string>(); var response = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json"); var abuseException = new AbuseException(response); Assert.False(abuseException.RetryAfterSeconds.HasValue); }
public void EmptyHeaderValue_RetryAfterSecondsDefaultsToNull(string emptyValueToTry) { var headerDictionary = new Dictionary <string, string> { { "Retry-After", emptyValueToTry } }; var response = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json"); var abuseException = new AbuseException(response); Assert.False(abuseException.RetryAfterSeconds.HasValue); }
public void WithZeroHeaderValue_RetryAfterSecondsIsZero() { var headerDictionary = new Dictionary <string, string> { { "Retry-After", "0" } }; var response = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json"); var abuseException = new AbuseException(response); Assert.Equal(0, abuseException.RetryAfterSeconds); }
public void WithRetryAfterHeader_PopulatesRetryAfterSeconds() { var headerDictionary = new Dictionary <string, string> { { "Retry-After", "30" } }; var response = new Response(HttpStatusCode.Forbidden, null, headerDictionary, "application/json"); var abuseException = new AbuseException(response); Assert.Equal(30, abuseException.RetryAfterSeconds); }
public void WithRetryAfterCaseInsensitiveHeader_PopulatesRetryAfterSeconds() { var headerDictionary = new Dictionary <string, string> { { "retry-after", "20" } }; var response = CreateResponse(HttpStatusCode.Forbidden, headerDictionary); var abuseException = new AbuseException(response); Assert.Equal(20, abuseException.RetryAfterSeconds); }
public void NegativeHeaderValue_RetryAfterSecondsDefaultsToNull() { var headerDictionary = new Dictionary <string, string> { { "Retry-After", "-123" } }; var response = CreateResponse(HttpStatusCode.Forbidden, headerDictionary); var abuseException = new AbuseException(response); Assert.False(abuseException.RetryAfterSeconds.HasValue); }
public void ContainsAbuseMessageFromApi() { const string responseBody = "{\"message\":\"You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.\"," + "\"documentation_url\":\"https://developer.github.com/v3/#abuse-rate-limits\"}"; var response = CreateResponse( HttpStatusCode.Forbidden, responseBody); var abuseException = new AbuseException(response); Assert.Equal("You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.", abuseException.ApiError.Message); }
public void ContainsAbuseMessageFromApi() { const string responseBody = "{\"error\":\"You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.\"," + "\"error_info\":\"https://developer.github.com/v3/#abuse-rate-limits\"}"; var response = new Response( HttpStatusCode.Forbidden, responseBody, new Dictionary <string, string>(), "application/json"); var abuseException = new AbuseException(response); Assert.Equal("You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.", abuseException.ApiError.Error); }