Skip to content
Merged
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 @@ -16,9 +16,14 @@ public async Task RunStep_CompletedStepDoesNotResetTimeoutAsync()

// Act
int firstResult = timeout.RunStep(_ => 1);
await Task.Delay(200);

// Wait for the timer callback itself; a fixed delay can finish first on a loaded runner.
var expired = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
using CancellationTokenRegistration registration = timeout.Token.Register(() => expired.TrySetResult(true));
Task completed = await Task.WhenAny(expired.Task, Task.Delay(TimeSpan.FromSeconds(30)));

// Assert
Assert.Same(expired.Task, completed);
Assert.Equal(1, firstResult);
Assert.Throws<TimeoutException>(() => timeout.RunStep(_ => 2));
}
Expand Down
Loading