public class FakeClock : IClock
Implementation of IClock which allows manually-specified times and increments.
Implements
IClockNamespace
Google.Api.Gax.TestingAssembly
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 | |
---|---|
Name | Description |
dateTime |
DateTime 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 | |
---|---|
Name | Description |
ticks |
long |
Methods
Advance(long)
public void Advance(long ticks)
Advances the clock by the given number of ticks.
Parameter | |
---|---|
Name | Description |
ticks |
long Ticks to advance the clock by. |
Advance(TimeSpan)
public void Advance(TimeSpan timeSpan)
Advances the clock by the given time span.
Parameter | |
---|---|
Name | Description |
timeSpan |
TimeSpan Time span to advance the clock by. |
AdvanceTo(DateTime)
public void AdvanceTo(DateTime dateTime)
Advances the clock to the given time.
Parameter | |
---|---|
Name | Description |
dateTime |
DateTime The time to advance to. |
GetCurrentDateTimeUtc()
public DateTime GetCurrentDateTimeUtc()
Returns the current date and time in UTC, with a kind of Utc.
Returns | |
---|---|
Type | Description |
DateTime |
A DateTime representing the clock's date and time in UTC. |