C# Class Google.Api.Gax.Testing.FakeClock

Implementation of IClock which allows manually-specified times and increments.
This implementation is thread-safe.
Inheritance: IClock
显示文件 Open project: googleapis/gax-dotnet Class Usage Examples

Public Methods

Method Description
Advance ( System.TimeSpan timeSpan ) : void

Advances the clock by the given time span.

Advance ( long ticks ) : void

Advances the clock by the given number of ticks.

AdvanceTo ( System.DateTime dateTime ) : void

Advances the clock to the given time.

FakeClock ( ) : System

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

FakeClock ( System.DateTime dateTime ) : System

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

FakeClock ( long ticks ) : System

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.

GetCurrentDateTimeUtc ( ) : System.DateTime

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

Method Details

Advance() public method

Advances the clock by the given time span.
public Advance ( System.TimeSpan timeSpan ) : void
timeSpan System.TimeSpan Time span to advance the clock by.
return void

Advance() public method

Advances the clock by the given number of ticks.
public Advance ( long ticks ) : void
ticks long Ticks to advance the clock by.
return void

AdvanceTo() public method

Advances the clock to the given time.
public AdvanceTo ( System.DateTime dateTime ) : void
dateTime System.DateTime The time to advance to.
return void

FakeClock() public method

Creates an instance with an initial time of 2000-01-01T00:00:00Z.
public FakeClock ( ) : System
return System

FakeClock() public method

Creates an instance with the specified initial time, which must have a kind of Utc or Unspecified (the latter being for convenience).
public FakeClock ( System.DateTime dateTime ) : System
dateTime System.DateTime The initial time for the clock.
return System

FakeClock() public method

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.
public FakeClock ( long ticks ) : System
ticks long
return System

GetCurrentDateTimeUtc() public method

Returns the current date and time in UTC, with a kind of DateTimeKind.Utc.
public GetCurrentDateTimeUtc ( ) : System.DateTime
return System.DateTime