TestClock class

Injectable clock for persistence assertions (bug #833, remediation 2).

TTL expiry is asserted virtually: advanceTime moves the clock forward without the wall clock moving, so a 24-hour TTL costs microseconds, not 24 hours — no real sleeps in the suite. The clock is an instance the owning test controls; advancing it never affects anything else.

The class is callable (DateTime Function()), so it plugs directly into every API that accepts a clock source, e.g. TtlCachePolicy(clock: ...).

Constructors

TestClock([DateTime? start])

Properties

hashCode → int
The hash code for this object.
no setterinherited
now → DateTime
The current (virtual) time.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

advanceTime(Duration duration) → void
Move the clock forward by duration — virtually, never by sleeping.
call() → DateTime
The clock as a plain DateTime source.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited