Table of Contents

Namespace TimeAssertions.TUnit

Classes

ActiveTimerAssertions

Fluent timer-leak assertions on an ObservableTimeProvider. The headline use case is verifying that hosted-service code (BackgroundService / IHostedService ping loops, heartbeats, debounce timers) disposes every ITimer it starts: wrap a FakeTimeProvider in an ObservableTimeProvider, run the code under test, then assert the active-timer set.

DateTimeOffsetAssertions

TimeProvider-aware DateTimeOffset assertions for recency / past / future checks against a (possibly fake) clock. TUnit core already provides IsInPast() / IsInFuture() using Now; these complement them with explicit TimeProvider injection so Microsoft.Extensions.Time.Testing.FakeTimeProvider-driven tests can verify time-relative state deterministically.

FakeTimeProviderAssertions

Fluent assertions on Microsoft.Extensions.Time.Testing.FakeTimeProvider instances. The headline use case for the family: tests that inject Microsoft.Extensions.Time.Testing.FakeTimeProvider into production code and then call Advance(TimeSpan) to simulate time passing can verify the resulting state with these assertions.

HasActiveTimerCountEventuallyAssertion

TUnit assertion that polls an ObservableTimeProvider in real time until its active timer count equals an expected value, or a timeout elapses. Generates the HasActiveTimerCountEventually(int, TimeSpan, ...) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

HasActiveTimersEventuallyAssertion

TUnit assertion that polls an ObservableTimeProvider in real time until at least one timer is active, or a timeout elapses. Generates the HasActiveTimersEventually(TimeSpan, ...) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

HasAtLeastActiveTimerCountEventuallyAssertion

TUnit assertion that polls an ObservableTimeProvider in real time until its active timer count is at least an expected lower bound, or a timeout elapses. Generates the HasAtLeastActiveTimerCountEventually(int, TimeSpan, ...) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

HasAtMostActiveTimerCountEventuallyAssertion

TUnit assertion that polls an ObservableTimeProvider in real time until its active timer count is at most an expected upper bound, or a timeout elapses. Generates the HasAtMostActiveTimerCountEventually(int, TimeSpan, ...) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

HasNoActiveTimersEventuallyAssertion

TUnit assertion that polls an ObservableTimeProvider in real time until no timer remains active, or a timeout elapses. Generates the HasNoActiveTimersEventually(TimeSpan, ...) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

RateLimitAssertions

Fluent rate-limit assertions on a chronologically-ordered sequence of invocation timestamps. The headline use case is a periodic-probe contract: "the failure handler must fire at most once per 30 seconds; subsequent failures inside that window are suppressed".

WithinTimeBudgetAssertion<T>

TUnit assertion that imposes a wall-clock timing budget on the preceding assertion source. Generates the WithinTimeBudget(TimeSpan) chain extension via TUnit's TUnit.Assertions.Attributes.AssertionExtensionAttribute source generator.

WithinTimeBudgetCapturingAssertion<T>

Capturing variant of WithinTimeBudgetAssertion<T>. Same wall-clock budget behaviour, but additionally invokes the supplied capture callback with the measured elapsed duration regardless of whether the budget was met. Useful for tests that need to log the observed timing or feed it into a follow-up HasAdvancedApproximately check.