Class EventuallyTimerAssertionExtensions
- Namespace
- TUnit.Assertions.Extensions
- Assembly
- TimeAssertions.TUnit.dll
Hand-written sugar overloads for the real-time "eventually" active-timer assertions that let a
caller pass a CancellationToken positionally while keeping the default poll
interval. They forward to the source-generated canonical extensions
(HasNoActiveTimersEventually, HasActiveTimerCountEventually,
HasAtLeastActiveTimerCountEventually, HasAtMostActiveTimerCountEventually,
HasActiveTimersEventually) with pollingInterval: null.
public static class EventuallyTimerAssertionExtensions
- Inheritance
-
EventuallyTimerAssertionExtensions
- Inherited Members
Remarks
The canonical extensions place the optional TimeSpan? pollingInterval parameter before the
CancellationToken, so the positional call HasNoActiveTimersEventually(timeout, token)
does not bind: a CancellationToken does not convert to Nullable<T>,
forcing the verbose cancellationToken: token named form. These overloads restore the natural
(timeout, token) and (count, timeout, token) shapes, matching TUnit's own
WaitsFor / Eventually convention where the token follows the timeout positionally.
Why the CancellationToken parameter has no default. If it defaulted, the
two-argument call HasNoActiveTimersEventually(timeout) would match both this overload and
the canonical one, producing a CS0121 ambiguity. With no default, the bare (timeout) call
binds only to the canonical extension, while the three-argument positional (timeout, token)
call binds only to this overload (the token cannot bind to the canonical's pollingInterval).
Methods
HasActiveTimerCountEventually(IAssertionSource<ObservableTimeProvider>, int, TimeSpan, CancellationToken, string?, string?)
Polls the live active-timer count until it equals count or
timeout elapses, using the default poll interval and the supplied
cancellationToken. The positional-token sugar for
HasActiveTimerCountEventually(count, timeout, pollingInterval: null,
cancellationToken: cancellationToken).
public static HasActiveTimerCountEventuallyAssertion HasActiveTimerCountEventually(this IAssertionSource<ObservableTimeProvider> source, int count, TimeSpan timeout, CancellationToken cancellationToken, string? countExpression = null, string? timeoutExpression = null)
Parameters
sourceIAssertionSource<ObservableTimeProvider>The assertion source over an ObservableTimeProvider.
countintThe active-timer count to poll for. Must be non-negative.
timeoutTimeSpanThe maximum wall-clock time to poll for the active-timer count to reach
count. Must be non-negative.cancellationTokenCancellationTokenA token that cancels the poll loop. This parameter has no default so the bare
HasActiveTimerCountEventually(count, timeout)call stays unambiguous against the canonical overload.countExpressionstringCaptured automatically; the caller's literal
countexpression, forwarded so failure messages name it.timeoutExpressionstringCaptured automatically; the caller's literal
timeoutexpression, forwarded so failure messages name it.
Returns
- HasActiveTimerCountEventuallyAssertion
The canonical HasActiveTimerCountEventuallyAssertion chain.
HasActiveTimersEventually(IAssertionSource<ObservableTimeProvider>, TimeSpan, CancellationToken, string?)
Polls the live active-timer count until at least one timer is active or timeout
elapses, using the default poll interval and the supplied cancellationToken.
The positional-token sugar for HasActiveTimersEventually(timeout, pollingInterval: null,
cancellationToken: cancellationToken).
public static HasActiveTimersEventuallyAssertion HasActiveTimersEventually(this IAssertionSource<ObservableTimeProvider> source, TimeSpan timeout, CancellationToken cancellationToken, string? timeoutExpression = null)
Parameters
sourceIAssertionSource<ObservableTimeProvider>The assertion source over an ObservableTimeProvider.
timeoutTimeSpanThe maximum wall-clock time to poll for. Must be non-negative.
cancellationTokenCancellationTokenA token that cancels the poll loop. This parameter has no default so the bare
HasActiveTimersEventually(timeout)call stays unambiguous against the canonical overload.timeoutExpressionstringCaptured automatically; the caller's literal
timeoutexpression, forwarded so failure messages name it.
Returns
- HasActiveTimersEventuallyAssertion
The canonical HasActiveTimersEventuallyAssertion chain.
HasAtLeastActiveTimerCountEventually(IAssertionSource<ObservableTimeProvider>, int, TimeSpan, CancellationToken, string?, string?)
Polls the live active-timer count until it is at least count or
timeout elapses, using the default poll interval and the supplied
cancellationToken. The positional-token sugar for
HasAtLeastActiveTimerCountEventually(count, timeout, pollingInterval: null,
cancellationToken: cancellationToken).
public static HasAtLeastActiveTimerCountEventuallyAssertion HasAtLeastActiveTimerCountEventually(this IAssertionSource<ObservableTimeProvider> source, int count, TimeSpan timeout, CancellationToken cancellationToken, string? countExpression = null, string? timeoutExpression = null)
Parameters
sourceIAssertionSource<ObservableTimeProvider>The assertion source over an ObservableTimeProvider.
countintThe minimum active-timer count to poll for. Must be non-negative.
timeoutTimeSpanThe maximum wall-clock time to poll for. Must be non-negative.
cancellationTokenCancellationTokenA token that cancels the poll loop. This parameter has no default so the bare
HasAtLeastActiveTimerCountEventually(count, timeout)call stays unambiguous against the canonical overload.countExpressionstringCaptured automatically; the caller's literal
countexpression, forwarded so failure messages name it.timeoutExpressionstringCaptured automatically; the caller's literal
timeoutexpression, forwarded so failure messages name it.
Returns
- HasAtLeastActiveTimerCountEventuallyAssertion
The canonical HasAtLeastActiveTimerCountEventuallyAssertion chain.
HasAtMostActiveTimerCountEventually(IAssertionSource<ObservableTimeProvider>, int, TimeSpan, CancellationToken, string?, string?)
Polls the live active-timer count until it is at most count or
timeout elapses, using the default poll interval and the supplied
cancellationToken. The positional-token sugar for
HasAtMostActiveTimerCountEventually(count, timeout, pollingInterval: null,
cancellationToken: cancellationToken).
public static HasAtMostActiveTimerCountEventuallyAssertion HasAtMostActiveTimerCountEventually(this IAssertionSource<ObservableTimeProvider> source, int count, TimeSpan timeout, CancellationToken cancellationToken, string? countExpression = null, string? timeoutExpression = null)
Parameters
sourceIAssertionSource<ObservableTimeProvider>The assertion source over an ObservableTimeProvider.
countintThe maximum active-timer count to poll for. Must be non-negative.
timeoutTimeSpanThe maximum wall-clock time to poll for. Must be non-negative.
cancellationTokenCancellationTokenA token that cancels the poll loop. This parameter has no default so the bare
HasAtMostActiveTimerCountEventually(count, timeout)call stays unambiguous against the canonical overload.countExpressionstringCaptured automatically; the caller's literal
countexpression, forwarded so failure messages name it.timeoutExpressionstringCaptured automatically; the caller's literal
timeoutexpression, forwarded so failure messages name it.
Returns
- HasAtMostActiveTimerCountEventuallyAssertion
The canonical HasAtMostActiveTimerCountEventuallyAssertion chain.
HasNoActiveTimersEventually(IAssertionSource<ObservableTimeProvider>, TimeSpan, CancellationToken, string?)
Polls the live active-timer count until it reaches zero or timeout elapses,
using the default poll interval and the supplied cancellationToken. The
positional-token sugar for HasNoActiveTimersEventually(timeout, pollingInterval: null,
cancellationToken: cancellationToken).
public static HasNoActiveTimersEventuallyAssertion HasNoActiveTimersEventually(this IAssertionSource<ObservableTimeProvider> source, TimeSpan timeout, CancellationToken cancellationToken, string? timeoutExpression = null)
Parameters
sourceIAssertionSource<ObservableTimeProvider>The assertion source over an ObservableTimeProvider.
timeoutTimeSpanThe maximum wall-clock time to poll for the active-timer count to reach zero. Must be non-negative.
cancellationTokenCancellationTokenA token that cancels the poll loop. This parameter has no default so the bare
HasNoActiveTimersEventually(timeout)call stays unambiguous against the canonical overload.timeoutExpressionstringCaptured automatically; the caller's literal
timeoutexpression, forwarded so failure messages name it.
Returns
- HasNoActiveTimersEventuallyAssertion
The canonical HasNoActiveTimersEventuallyAssertion chain.