Table of Contents

Class WaitForHelper<T>

Namespace
Bunit.Extensions.WaitForHelpers
Assembly
Bunit.Core.dll

Represents a helper class that can wait for a render notifications from a IRenderedFragmentBase type, until a specific timeout is reached.

public abstract class WaitForHelper<T> : IDisposable

Type Parameters

T
Inheritance
WaitForHelper<T>
Implements
Derived
Inherited Members
Extension Methods

Constructors

WaitForHelper(IRenderedFragmentBase, Func<(bool CheckPassed, T Content)>, TimeSpan?)

Initializes a new instance of the WaitForHelper<T> class.

protected WaitForHelper(IRenderedFragmentBase renderedFragment, Func<(bool CheckPassed, T Content)> completeChecker, TimeSpan? timeout = null)

Parameters

renderedFragment IRenderedFragmentBase
completeChecker Func<(bool CheckPassed, T Content)>
timeout TimeSpan?

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 virtual string? CheckThrowErrorMessage { get; }

Property Value

string

StopWaitingOnCheckException

Gets a value indicating whether to continue waiting if the wait condition checker throws.

protected abstract bool StopWaitingOnCheckException { get; }

Property Value

bool

TimeoutErrorMessage

Gets the error message passed to the user when the wait for helper times out.

protected virtual string? TimeoutErrorMessage { get; }

Property Value

string

WaitTask

Gets the task that will complete successfully if the check passed before the timeout was reached. The task will complete with an WaitForFailedException exception if the timeout was reached without the check passing.

public Task<T> WaitTask { get; }

Property Value

Task<T>

Methods

Dispose()

Disposes the wait helper and cancels the any ongoing waiting, if it is not already in one of the other completed states.

public void Dispose()

Dispose(bool)

Disposes of the wait task and related logic.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

Set to true if called from Dispose(), false if called from a finalizer.f.

Remarks

The disposing parameter should be false when called from a finalizer, and true when called from the Dispose() method. In other words, it is true when deterministically called and false when non-deterministically called.

.NET Foundation

Supported by the .NET Foundation.