Class FakeClock (3.2.0)

public class FakeClock : IClock

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

Inheritance

Object > FakeClock

Implements

IClock

Namespace

Google.Api.Gax.Testing

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(Int64)

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
ticksInt64

Methods

Advance(Int64)

public void Advance(long ticks)

Advances the clock by the given number of ticks.

Parameter
NameDescription
ticksInt64

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.