-
Notifications
You must be signed in to change notification settings - Fork 848
Description
Description
This is how I expect it to work, not sure if it's a bug, intentional or an oversight.
var advanceAmount = TimeSpan.FromSeconds(5);
var provider = new FakeTimeProvider
{
AutoAdvanceAmount = TimeSpan.FromSeconds(5)
};
/// .. non test code
var startingTimestamp = provider.GetTimestamp();
/// ... things happening in between
var elapsedTime = provider.GetElapsedTime(startingTimestamp);
/// ... test code
// expected to be true but is 0
Assert.That(elapsedTime, Is.EqualTo(advanceAmount))Reproduction Steps
As above ^^
Expected behavior
I would expect that when checking the elapsed time that it should match what is specified in AutoAdvanceAmount.
Actual behavior
The elapsed time is zero.
Regression?
No idea.
Known Workarounds
Currently I can work around the issue by advancing the timer myself in between the calls to GetTimestamp and GetElapsedTime.
Configuration
.NET 8
Other information
extensions/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs
Line 165 in cfed375
| public override long GetTimestamp() |
This shows that it just returns the number of ticks from now.
Maybe it needs to do something similar to
extensions/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs
Line 83 in cfed375
| _now += _autoAdvanceAmount; |