Skip to content

Commit

Permalink
Updates (tests, max delay)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski committed May 7, 2021
1 parent c13cc96 commit db816ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core/src/Shared/OperationInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public async ValueTask<Response<TResult>> WaitForCompletionAsync(TimeSpan pollin

var serverDelay = GetServerDelay(response);

var delay = Math.Max(serverDelay, pollingInterval);
var delay = serverDelay > pollingInterval
? serverDelay : pollingInterval;

await WaitAsync(delay, cancellationToken).ConfigureAwait(false);
}
Expand Down
16 changes: 6 additions & 10 deletions sdk/core/Azure.Core/tests/OperationInternalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ public async Task UpdateStatusWhenOperationSucceeds(bool async)
}

[Test]
[TestCase(true, true)]
[TestCase(true, false)]
[TestCase(false, true)]
[TestCase(false, false)]
public void UpdateStatusWhenOperationFails(bool async, bool useDefaultException)
public void UpdateStatusWhenOperationFails(
[Values(true, false)] bool async,
[Values(true, false)] bool useDefaultException)
{
var originalException = new RequestFailedException("");
var mockResponse = new MockResponse(200);
Expand Down Expand Up @@ -385,11 +383,9 @@ public async Task WaitForCompletionUsesRetryAfterHeader(bool useDefaultPollingIn
}

[Test]
[TestCase(true, "retry-after-ms")]
[TestCase(true, "x-ms-retry-after-ms")]
[TestCase(false, "retry-after-ms")]
[TestCase(false, "x-ms-retry-after-ms")]
public async Task WaitForCompletionUsesRetryAfterMsHeader(bool useDefaultPollingInterval, string headerName)
public async Task WaitForCompletionUsesRetryAfterMsHeader(
[Values(true, false)] bool useDefaultPollingInterval,
[Values("retry-after-ms", "x-ms-retry-after-ms")] string headerName)
{
var originalDelay = TimeSpan.FromMilliseconds(500);
var shortDelay = originalDelay.Subtract(TimeSpan.FromMilliseconds(250));
Expand Down

0 comments on commit db816ea

Please sign in to comment.