Class ProtoRequestClock

Namespace
ProtoTest.Core
Assembly
ProtoTest.Core.dll

The clock in effect for the current request or flow. A hosting integration that runs an application in-process pushes the test's clock while it handles a request the test caused, so application code that resolves TimeProvider sees the test's time; background flows see the run's.

public static class ProtoRequestClock
Inheritance
ProtoRequestClock
Inherited Members

Remarks

A push restores whatever clock was in effect before it when its scope is disposed; it does not revoke the pushed clock from flows that captured it. A fire-and-forget task started inside a request keeps the finished test's clock after the request and the test end, so long-lived background work must read the run clock instead of the ambient one. The lookup that links a request to a test is scoped to the host that owns the test (FindClock(string)).

Properties

Current

Gets the pushed clock, or null when the flow has none.

public static ProtoClock? Current { get; }

Property Value

ProtoClock

Methods

Push(ProtoClock)

Makes clock the clock of the current flow until the returned scope is disposed, restoring whatever clock was in effect before. Hosting integrations call this around the work a test caused.

public static IDisposable Push(ProtoClock clock)

Parameters

clock ProtoClock

Returns

IDisposable