public async Task RetryPolicyRetriesOnTransientErrorInPut(HttpStatusCode errorCode) { _mockHttp.Expect("https://sample.servicebus.windows.net/hub-name") .Respond(errorCode); _mockHttp.Expect("https://sample.servicebus.windows.net/hub-name") .Respond(HttpStatusCode.OK, "application/xml", _hubResponse); await _namespaceClient.CreateNotificationHubAsync(_hubName); _mockHttp.VerifyNoOutstandingExpectation(); }
public async Task RetryPolicyGivesUpAfterTimeout() { _namespaceClient = new NamespaceManager(_connectionString, new NotificationHubSettings { MessageHandler = _mockHttp, RetryOptions = new NotificationHubRetryOptions { Delay = TimeSpan.FromMilliseconds(10), MaxRetries = 1 } }); _mockHttp.Expect("https://sample.servicebus.windows.net/hub-name") .Throw(new TimeoutException()); _mockHttp.Expect("https://sample.servicebus.windows.net/hub-name") .Throw(new TimeoutException()); _mockHttp.Expect("https://sample.servicebus.windows.net/hub-name") .Respond(HttpStatusCode.OK, "application/xml", _hubResponse); await Assert.ThrowsAsync <TimeoutException>(() => _namespaceClient.CreateNotificationHubAsync(_hubName)); }