Skip to content

feat: allow disabling auto-advance of time in MockTimeSystem#971

Merged
vbreuss merged 4 commits intomainfrom
topic/support-disabling-timesystem-autoadvance
Mar 16, 2026
Merged

feat: allow disabling auto-advance of time in MockTimeSystem#971
vbreuss merged 4 commits intomainfrom
topic/support-disabling-timesystem-autoadvance

Conversation

@vbreuss
Copy link
Member

@vbreuss vbreuss commented Mar 16, 2026

Adds an opt-out for MockTimeSystem’s default behavior of auto-advancing simulated time when waiting via Task.Delay, Thread.Sleep, and PeriodicTimer.

Key Changes:

  • Introduces MockTimeSystemOptions and new constructor overloads to allow DisableAutoAdvance().
  • Threads the autoAdvance flag through TaskMock, ThreadMock, and PeriodicTimer mocks/factory.
  • Adds tests covering disabled auto-advance behavior for delay/sleep and periodic timers.

@vbreuss vbreuss self-assigned this Mar 16, 2026
Copilot AI review requested due to automatic review settings March 16, 2026 12:44
@vbreuss vbreuss added the enhancement New feature or request label Mar 16, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-out for MockTimeSystem’s default behavior of auto-advancing simulated time when waiting via Task.Delay, Thread.Sleep, and PeriodicTimer.

Changes:

  • Introduces MockTimeSystemOptions and new constructor overloads to allow DisableAutoAdvance().
  • Threads the autoAdvance flag through TaskMock, ThreadMock, and PeriodicTimer mocks/factory.
  • Adds tests covering disabled auto-advance behavior for delay/sleep and periodic timers.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/Testably.Abstractions.Testing.Tests/MockTimeSystemTests.cs Adds new tests verifying behavior when auto-advance is disabled.
Source/Testably.Abstractions.Testing/TimeSystem/ThreadMock.cs Makes Thread.Sleep optionally stop advancing the mock time.
Source/Testably.Abstractions.Testing/TimeSystem/TaskMock.cs Makes Task.Delay optionally stop advancing the mock time.
Source/Testably.Abstractions.Testing/TimeSystem/PeriodicTimerMock.cs Implements non-auto-advance behavior by waiting for manual time changes.
Source/Testably.Abstractions.Testing/TimeSystem/PeriodicTimerFactoryMock.cs Passes the autoAdvance setting into created periodic timers.
Source/Testably.Abstractions.Testing/MockTimeSystem.cs Adds options-based constructors and wires the option into mocks/factories.

@vbreuss vbreuss enabled auto-merge (squash) March 16, 2026 13:20
@sonarqubecloud
Copy link

@vbreuss vbreuss merged commit 1666aa9 into main Mar 16, 2026
13 checks passed
@vbreuss vbreuss deleted the topic/support-disabling-timesystem-autoadvance branch March 16, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants