Class WaitForStateHelper
- Namespace
- Bunit.Extensions.WaitForHelpers
- Assembly
- Bunit.Core.dll
Represents an async wait helper, that will wait for a specified time for a state predicate to pass.
public class WaitForStateHelper : WaitForHelper<object?>, IDisposable
- Inheritance
-
WaitForStateHelper
- Implements
- Inherited Members
- Extension Methods
Constructors
WaitForStateHelper(IRenderedFragmentBase, Func<bool>, TimeSpan?)
Initializes a new instance of the WaitForStateHelper class,
which will wait until the provided statePredicate
action returns true,
or the timeout
is reached (default is one second).
public WaitForStateHelper(IRenderedFragmentBase renderedFragment, Func<bool> statePredicate, TimeSpan? timeout = null)
Parameters
renderedFragment
IRenderedFragmentBaseThe render fragment or component to attempt to verify state against.
statePredicate
Func<bool>The predicate to invoke after each render, which must returns
true
when the desired state has been reached.timeout
TimeSpan?The maximum time to wait for the desired state.
Remarks
The statePredicate
is evaluated initially, and then each time the renderedFragment
renders.
Exceptions
- WaitForFailedException
Thrown if the
statePredicate
throw an exception during invocation, or if the timeout has been reached. See the inner exception for details.
Properties
CheckThrowErrorMessage
Gets the error message passed to the user when the wait for checker throws an exception. Only used if StopWaitingOnCheckException is true.
protected override string? CheckThrowErrorMessage { get; }
Property Value
StopWaitingOnCheckException
Gets a value indicating whether to continue waiting if the wait condition checker throws.
protected override bool StopWaitingOnCheckException { get; }
Property Value
TimeoutErrorMessage
Gets the error message passed to the user when the wait for helper times out.
protected override string? TimeoutErrorMessage { get; }