Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ await Assert.ThrowsAsync<OperationCanceledException>(async ()

waitException.WaitOne();
await Task.Delay(TimeSpan.FromSeconds(4));
}, 3, TimeSpan.FromSeconds(3), _ => true);
}, 3, TimeSpan.FromSeconds(3));

[TestMethod]
public async Task CancellationAsyncWithReturnValue_ObserveException_Succeeds()
Expand All @@ -111,7 +111,7 @@ await Assert.ThrowsAsync<OperationCanceledException>(async ()

waitException.WaitOne();
await Task.Delay(TimeSpan.FromSeconds(4));
}, 3, TimeSpan.FromSeconds(3), _ => true);
}, 3, TimeSpan.FromSeconds(3));

private static async Task<string> DoSomething()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace Microsoft.Testing.TestInfrastructure;

public class RetryHelper
{
public static async Task RetryAsync(Func<Task> action, uint times, TimeSpan every, Func<Exception, bool>? predicate = null)
=> await Policy.Handle<Exception>(exception => predicate is null || predicate(exception))
public static async Task RetryAsync(Func<Task> action, uint times, TimeSpan every)
=> await Policy.Handle<Exception>()
.WaitAndRetryAsync((int)times, _ => every)
.ExecuteAsync(action);

public static async Task<T> RetryAsync<T>(Func<Task<T>> action, uint times, TimeSpan every, Func<Exception, bool>? predicate = null)
=> await Policy.Handle<Exception>(exception => predicate is null || predicate(exception))
public static async Task<T> RetryAsync<T>(Func<Task<T>> action, uint times, TimeSpan every)
=> await Policy.Handle<Exception>()
.WaitAndRetryAsync((int)times, _ => every)
.ExecuteAsync(action);
}