Skip to main content

TestClock class

Namespace: Arlecchino.Testing · Assembly: Arlecchino.Testing

A clock a test moves by hand. Scheduled work runs when the clock passes its due time, so a second is moved rather than waited for.

public sealed class TestClock : TimeProvider

Inherits from TimeProvider

Constructors

MemberSummary
TestClock()

Methods

MemberSummary
Advance(TimeSpan)Moves the clock forward.
GetUtcNow()The time the clock reads now.

Constructors in detail

TestClock()

public TestClock();

Methods in detail

Advance(TimeSpan)

public void Advance(TimeSpan amount);

Moves the clock forward.

Parameters

NameTypeDescription
amountTimeSpanHow far ahead; a negative amount leaves the clock where it is.

GetUtcNow()

public override DateTimeOffset GetUtcNow();

The time the clock reads now.

Returns DateTimeOffset — The current time.