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 @@ -104,7 +104,8 @@ await Assertions

await AsyncTestHelpers.AssertIsTrueRetryAsync(
async () => await checkbox.IsCheckedAsync(),
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The lambda 'async () => await checkbox.IsCheckedAsync()' could be simplified to '() => checkbox.IsCheckedAsync()' since there's no additional async processing required, which can make the code more concise.

Suggested change
async () => await checkbox.IsCheckedAsync(),
() => checkbox.IsCheckedAsync(),

Copilot uses AI. Check for mistakes.

"Checkbox isn't immediately checked.");
"Checkbox isn't immediately checked.",
retries: 15 /* this seems to take a very long time to run, so needs a long timeout */);
}
});
}
Expand Down
12 changes: 5 additions & 7 deletions tests/Shared/AsyncTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,16 @@ private static string CreateMessage(TimeSpan timeout, string filePath, int lineN
? $"The operation timed out after reaching the limit of {timeout.TotalMilliseconds}ms."
: $"The operation at {filePath}:{lineNumber} timed out after reaching the limit of {timeout.TotalMilliseconds}ms.";

public static Task AssertIsTrueRetryAsync(Func<bool> assert, string message, ILogger? logger = null)
public static Task AssertIsTrueRetryAsync(Func<bool> assert, string message, ILogger? logger = null, int retries = 10)
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the method documentation for AssertIsTrueRetryAsync to include details about the new 'retries' parameter and its impact on the timeout behavior.

Copilot uses AI. Check for mistakes.

{
return AssertIsTrueRetryAsync(() => Task.FromResult(assert()), message, logger);
return AssertIsTrueRetryAsync(() => Task.FromResult(assert()), message, logger, retries);
}

public static async Task AssertIsTrueRetryAsync(Func<Task<bool>> assert, string message, ILogger? logger = null)
public static async Task AssertIsTrueRetryAsync(Func<Task<bool>> assert, string message, ILogger? logger = null, int retries = 10)
{
const int Retries = 10;

logger?.LogInformation("Start: " + message);

for (var i = 0; i < Retries; i++)
for (var i = 0; i < retries; i++)
{
if (i > 0)
{
Expand All @@ -220,6 +218,6 @@ public static async Task AssertIsTrueRetryAsync(Func<Task<bool>> assert, string
}
}

throw new InvalidOperationException($"Assert failed after {Retries} retries: {message}");
throw new InvalidOperationException($"Assert failed after {retries} retries: {message}");
}
}
Loading