fix: correctly handle missing auto-advance in ITimer#990
Conversation
ITimer does not wait for time to advance before invoking callbackITimer
ITimerITimer
There was a problem hiding this comment.
Pull request overview
Fixes mocked ITimer behavior in MockTimeSystem so that, when auto-advancing time is disabled, timer callbacks are not invoked until the mocked time is explicitly advanced—bringing timer behavior in line with the rest of the time system abstractions.
Changes:
- Thread auto-advance configuration into
TimerFactoryMock/TimerMockand update timer scheduling accordingly. - Update
TimerMockexecution loop to wait based on planned execution ticks instead of always delaying via mockedTask.Delay. - Add/adjust tests covering
DisableAutoAdvancetimer behavior and correct a timer period in an existing time-change parity test.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerMockTests.cs | Adds new tests for DisableAutoAdvance timer behavior; adjusts period in ShouldNotBeAffectedByTimeChange. |
| Source/Testably.Abstractions.Testing/TimeSystem/TimerMock.cs | Implements non-auto-advance waiting via On.TimeChanged and planned execution ticks; adds _autoAdvance plumbing. |
| Source/Testably.Abstractions.Testing/TimeSystem/TimerFactoryMock.cs | Propagates AutoAdvance into created TimerMock instances. |
| Source/Testably.Abstractions.Testing/MockTimeSystem.cs | Passes initialization.AutoAdvance into TimerFactoryMock. |
031e11f to
fcd9636
Compare
Test Results 62 files - 40 62 suites - 40 1h 38m 18s ⏱️ - 51m 45s Results for commit fcd9636. ± Comparison against base commit af46ef8. This pull request removes 109805 and adds 70682 tests. Note that renamed tests count towards both.This pull request removes 12569 skipped tests and adds 8292 skipped tests. Note that renamed tests count towards both.This pull request skips 31 tests. |
|
|
This is addressed in release v6.2.0. |



Fixes mocked
ITimerbehavior inMockTimeSystemso that, when auto-advancing time is disabled, timer callbacks are not invoked until the mocked time is explicitly advanced—bringing timer behavior in line with the rest of the time system abstractions.Changes:
TimerFactoryMock/TimerMockand update timer scheduling accordingly.TimerMockexecution loop to wait based on planned execution ticks instead of always delaying via mockedTask.Delay.DisableAutoAdvancetimer behavior and correct a timer period in an existing time-change parity test.