Skip to content

Commit 62d128a

Browse files
authored
Fix TimeProvider Test (#111080)
1 parent 1a97d63 commit 62d128a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libraries/Common/tests/System/TimeProviderTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ public void TestProviderTimer(TimeProvider provider, int minMilliseconds)
143143
state.TokenSource.Token.WaitHandle.WaitOne(Timeout.InfiniteTimeSpan);
144144
state.TokenSource.Dispose();
145145

146-
Assert.Equal(4, state.Counter);
146+
// In normal conditions, the timer callback should be called 4 times. Sometimes the timer callback could be queued and fired after the timer was disposed.
147+
Assert.True(state.Counter >= 4, $"The timer callback was expected to be called at least 4 times, but was called {state.Counter} times");
148+
147149
Assert.Equal(400, state.Period);
148150
Assert.True(minMilliseconds <= state.Stopwatch.ElapsedMilliseconds, $"The total fired periods {state.Stopwatch.ElapsedMilliseconds}ms expected to be greater then the expected min {minMilliseconds}ms");
149151
}

0 commit comments

Comments
 (0)