Skip to content

FakeTimeProvider does not advance when GetTimestamp is called #5694

Closed
@ItsVeryWindy

Description

@ItsVeryWindy

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

This shows that it just returns the number of ticks from now.

Maybe it needs to do something similar to

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions