feat: add Stopwatch support to ITimeSystem#943
Merged
Conversation
7af03b5 to
01e3f72
Compare
There was a problem hiding this comment.
Pull request overview
Adds a System.Diagnostics.Stopwatch abstraction to ITimeSystem, enabling both RealTimeSystem and MockTimeSystem consumers to create/use stopwatches through a testable interface.
Changes:
- Introduces
IStopwatchandIStopwatchFactoryand wires them intoITimeSystem,RealTimeSystem, andMockTimeSystem. - Implements real wrappers (
StopwatchFactory/StopwatchWrapper) and mock implementations (StopwatchFactoryMock/StopwatchMock), plus parity and unit tests. - Adjusts build/project configuration (conditional PackageReference vs ProjectReference for the Interface project, feature flag for
Stopwatch.GetElapsedTime, pipeline + versioning tweaks).
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs | New time-system tests for IStopwatch behavior. |
| Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs | New tests for IStopwatchFactory static-like members and GetElapsedTime (feature-gated). |
| Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs | New mock-specific precision test for tick-based elapsed behavior. |
| Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Tests/Testably.Abstractions.Parity.Tests/Testably.Abstractions.Parity.Tests.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference; refactors Compression reference group. |
| Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Parity.cs | Adds parity configuration for Stopwatch comparisons. |
| Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs | Adds parity test for IStopwatch/IStopwatchFactory vs System.Diagnostics.Stopwatch. |
| Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Source/Testably.Abstractions/TimeSystem/TimerFactory.cs | Fixes incorrect <inheritdoc> cref for Wrap(Timer). |
| Source/Testably.Abstractions/TimeSystem/StopwatchWrapper.cs | New real wrapper implementing IStopwatch. |
| Source/Testably.Abstractions/TimeSystem/StopwatchFactory.cs | New real factory implementing IStopwatchFactory. |
| Source/Testably.Abstractions/Testably.Abstractions.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Source/Testably.Abstractions/RealTimeSystem.cs | Adds Stopwatch factory property and initialization. |
| Source/Testably.Abstractions.Testing/TimeSystem/TimerFactoryMock.cs | Fixes incorrect <inheritdoc> cref for Wrap(Timer). |
| Source/Testably.Abstractions.Testing/TimeSystem/StopwatchMock.cs | New mock stopwatch implementation based on mocked time provider. |
| Source/Testably.Abstractions.Testing/TimeSystem/StopwatchFactoryMock.cs | New mock stopwatch factory implementing IStopwatchFactory. |
| Source/Testably.Abstractions.Testing/Testably.Abstractions.Testing.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Source/Testably.Abstractions.Testing/MockTimeSystem.cs | Adds Stopwatch property; renames internal timer factory field for clarity. |
| Source/Testably.Abstractions.Testing/Helpers/ExceptionFactory.cs | Adds NotSupported exception factory for stopwatch wrapping in mock. |
| Source/Testably.Abstractions.Interface/TimeSystem/IStopwatchFactory.cs | New public stopwatch factory abstraction. |
| Source/Testably.Abstractions.Interface/TimeSystem/IStopwatch.cs | New public stopwatch abstraction. |
| Source/Testably.Abstractions.Interface/ITimeSystem.cs | Adds Stopwatch property to the time system abstraction. |
| Source/Testably.Abstractions.Compression/Testably.Abstractions.Compression.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Source/Testably.Abstractions.AccessControl/Testably.Abstractions.AccessControl.csproj | Debug uses Interface ProjectReference; non-Debug uses PackageReference. |
| Source/Directory.Build.props | Sets a local build Version fallback (intended to be overridden in pipeline). |
| Pipeline/Build.cs | Changes default BuildScope (affects CI target gating). |
| Feature.Flags.props | Adds FEATURE_STOPWATCH_GETELAPSEDTIME for net8+. |
Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs
Outdated
Show resolved
Hide resolved
Source/Testably.Abstractions.Interface/TimeSystem/IStopwatchFactory.cs
Outdated
Show resolved
Hide resolved
Source/Testably.Abstractions.Testing/TimeSystem/StopwatchMock.cs
Outdated
Show resolved
Hide resolved
Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs
Outdated
Show resolved
Hide resolved
2ff34a7 to
96ed83d
Compare
96ed83d to
1252944
Compare
|
This is addressed in release v5.3.0. |
This was referenced Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
System.Diagnostics.Stopwatchabstraction toITimeSystem, enabling bothRealTimeSystemandMockTimeSystemconsumers to create/use stopwatches through a testable interface.Key Changes:
IStopwatchandIStopwatchFactoryand wires them intoITimeSystem,RealTimeSystem, andMockTimeSystem.StopwatchFactory/StopwatchWrapper) and mock implementations (StopwatchFactoryMock/StopwatchMock), plus parity and unit tests.Stopwatch.GetElapsedTime(.NET 8 or higher)