fix: GetTimestamp in mocked stopwatch should correlate to frequency#973
fix: GetTimestamp in mocked stopwatch should correlate to frequency#973
GetTimestamp in mocked stopwatch should correlate to frequency#973Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the mocked IStopwatchFactory.GetTimestamp() implementation so that timestamp deltas align with the factory’s reported Frequency (i.e., (t2 - t1) / Frequency yields elapsed seconds), and adds a regression test to validate that behavior.
Changes:
- Update
StopwatchFactoryMock.GetTimestamp()to scale the returned timestamp by_tickPeriodso it correlates withFrequency. - Add a new test asserting
(timestampDelta / Frequency) ≈ 1 secondafter aTimeSystem.Task.Delay.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs | Adds a regression test that validates timestamp/frequency correlation using a 1-second delay. |
| Source/Testably.Abstractions.Testing/TimeSystem/StopwatchFactoryMock.cs | Changes mocked stopwatch timestamp units to match the configured frequency scaling. |
Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs
Outdated
Show resolved
Hide resolved
Test Results 102 files ± 0 102 suites ±0 2h 24m 1s ⏱️ -1s Results for commit 22d5cfb. ± Comparison against base commit 8b1629f. This pull request removes 109661 and adds 109663 tests. Note that renamed tests count towards both.This pull request removes 12552 skipped tests and adds 12552 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|



This PR fixes the mocked
IStopwatchFactory.GetTimestamp()implementation so that timestamp deltas align with the factory’s reportedFrequency(i.e.,(t2 - t1) / Frequencyyields elapsed seconds), and adds a regression test to validate that behavior.Key Changes:
StopwatchFactoryMock.GetTimestamp()to scale the returned timestamp by_tickPeriodso it correlates withFrequency.(timestampDelta / Frequency) ≈ 1 secondafter aTimeSystem.Task.Delay.