Class FakeClock (4.3.1)

public class FakeClock : IClock

Implementation of IClock which allows manually-specified times and increments.

Inheritance

object > FakeClock

Implements

IClock

Namespace

GoogleGoogle.ApiGaxTesting

Assembly

Google.Api.Gax.Testing.dll

Remarks

This implementation is thread-safe.

Constructors

FakeClock()

public FakeClock()

Creates an instance with an initial time of 2000-01-01T00:00:00Z.

FakeClock(DateTime)

public FakeClock(DateTime dateTime)

Creates an instance with the specified initial time, which must have a kind of Utc or Unspecified (the latter being for convenience).

Parameter
NameDescription
dateTimeDateTime

The initial time for the clock.

FakeClock(long)

public FakeClock(long ticks)

Creates an instance with the specified number of ticks since 0001-01-1T00:00:00Z as the initial time, for convenience when testing code with numeric values.

Parameter
NameDescription
tickslong

Methods

Advance(long)

public void Advance(long ticks)

Advances the clock by the given number of ticks.

Parameter
NameDescription
tickslong

Ticks to advance the clock by.

Advance(TimeSpan)

public void Advance(TimeSpan timeSpan)

Advances the clock by the given time span.

Parameter
NameDescription
timeSpanTimeSpan

Time span to advance the clock by.

AdvanceTo(DateTime)

public void AdvanceTo(DateTime dateTime)

Advances the clock to the given time.

Parameter
NameDescription
dateTimeDateTime

The time to advance to.

GetCurrentDateTimeUtc()

public DateTime GetCurrentDateTimeUtc()

Returns the current date and time in UTC, with a kind of Utc.

Returns
TypeDescription
DateTime

A DateTime representing the clock's date and time in UTC.