Class TestWaitCondition
Contains extension methods on ITestWaitCondition<T>.
Namespace: Responsible
Assembly: Responsible.dll
Syntax
public static class TestWaitCondition
Methods
AndThen<TFirst, TSecond>(ITestWaitCondition<TFirst>, ITestWaitCondition<TSecond>, string, string, int)
Constructs a wait condition, which will first wait for the first condition to be fulfilled,
and only then continue waiting on the second.
The result of first
is discarded.
Will complete with a failure, if either condition fails.
Declaration
[Pure]
public static ITestWaitCondition<TSecond> AndThen<TFirst, TSecond>(this ITestWaitCondition<TFirst> first, ITestWaitCondition<TSecond> second, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TFirst> | first | First wait condition to wait on. |
ITestWaitCondition<TSecond> | second | Second wait condition to wait on. |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestWaitCondition<TSecond> | A wait condition which is completed with the result of |
Type Parameters
Name | Description |
---|---|
TFirst | Result type of first wait condition. |
TSecond | Result type of second wait condition and the returned wait condition. |
AndThen<TFirst, TSecond>(ITestWaitCondition<TFirst>, Func<TFirst, ITestWaitCondition<TSecond>>, string, string, int)
Constructs a wait condition, which will first wait for the first condition to be fulfilled,
then construct a second condition using continuation
, and continue waiting on it.
Will complete with a failure, if either condition, or the continuation function fails.
Declaration
[Pure]
public static ITestWaitCondition<TSecond> AndThen<TFirst, TSecond>(this ITestWaitCondition<TFirst> first, Func<TFirst, ITestWaitCondition<TSecond>> continuation, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TFirst> | first | First wait condition to wait on. |
Func<TFirst, ITestWaitCondition<TSecond>> | continuation | Continuation function to build the second wait condition from the result of |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestWaitCondition<TSecond> | A wait condition which is completed with the result of the wait condition returned by
|
Type Parameters
Name | Description |
---|---|
TFirst | Result type of first wait condition. |
TSecond | Result type of second wait condition and the returned wait condition. |
BoxResult<T>(ITestWaitCondition<T>)
Converts a wait condition returning a value type into one returning the same value boxed into object.
Declaration
[Pure]
public static ITestWaitCondition<object> BoxResult<T>(this ITestWaitCondition<T> condition) where T : struct
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<T> | condition | Wait condition to wrap. |
Returns
Type | Description |
---|---|
ITestWaitCondition<object> | A wait condition which behaves otherwise identically to |
Type Parameters
Name | Description |
---|---|
T | Return type of the wait condition to convert. |
ExpectWithinSeconds<T>(ITestWaitCondition<T>, double, string, string, int)
Constructs a test instruction, which will enforce a timeout on the provided wait condition. If the condition isn't met within the timeout, the instruction will complete with an error.
Declaration
[Pure]
public static ITestInstruction<T> ExpectWithinSeconds<T>(this ITestWaitCondition<T> condition, double timeout, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<T> | condition | Wait condition to wait for. |
double | timeout | Timeout for waiting for the condition, in seconds. |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestInstruction<T> | A test instruction which completes with the result of the condition, or a failure if either the timeout is met, or the condition completes with a failure. |
Type Parameters
Name | Description |
---|---|
T | Result type of the wait condition, and the returned instruction. |
Select<T1, T2>(ITestWaitCondition<T1>, Func<T1, T2>, string, string, int)
Applies a selector to the result of a wait condition when the condition completes, transforming the result type to another type.
Declaration
[Pure]
public static ITestWaitCondition<T2> Select<T1, T2>(this ITestWaitCondition<T1> condition, Func<T1, T2> selector, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<T1> | condition | A wait condition to apply the selector to. |
Func<T1, T2> | selector | A function to apply to the result of the wait condition. |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestWaitCondition<T2> | A wait condition whose result is the result of invoking
|
Type Parameters
Name | Description |
---|---|
T1 | Return type of the initial wait condition. |
T2 | Return type of the selector and the returned wait condition. |
ThenRespondWithAction<TWait>(ITestWaitCondition<TWait>, string, Action<TWait>, string, string, int)
Constructs a test responder, which will wait for the given condition, and then continue executing a synchronous action, returning a non-null object. Will complete with a failure if the wait condition or action completes with a failure.
Declaration
[Pure]
public static ITestResponder<object> ThenRespondWithAction<TWait>(this ITestWaitCondition<TWait> condition, string description, Action<TWait> action, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TWait> | condition | Condition to wait on before executing |
string | description | Description of the responder which is constructed. |
Action<TWait> | action | Synchronous action to execute with the result of |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestResponder<object> | A test responder composed of |
Type Parameters
Name | Description |
---|---|
TWait | Result type of the wait condition. |
ThenRespondWithFunc<TWait, TResult>(ITestWaitCondition<TWait>, string, Func<TWait, TResult>, string, string, int)
Constructs a test responder, which will wait for the provided condition, and then continue executing a synchronous function, returning its result. Will complete with a failure if the wait condition or function completes with a failure.
Declaration
[Pure]
public static ITestResponder<TResult> ThenRespondWithFunc<TWait, TResult>(this ITestWaitCondition<TWait> condition, string description, Func<TWait, TResult> selector, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TWait> | condition | Condition to wait on before executing |
string | description | Description of the responder which is constructed. |
Func<TWait, TResult> | selector | Synchronous function to execute with the result of |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestResponder<TResult> | A test responder composed of |
Type Parameters
Name | Description |
---|---|
TWait | Result type of the wait condition. |
TResult | Result type of the instruction and the returned responder. |
ThenRespondWith<TWait, TResult>(ITestWaitCondition<TWait>, string, ITestInstruction<TResult>, string, string, int)
Constructs a test responder, which will wait for the provided condition, and then continue executing the provided instruction. Will complete with a failure if the wait condition or instruction completes with a failure.
Declaration
[Pure]
public static ITestResponder<TResult> ThenRespondWith<TWait, TResult>(this ITestWaitCondition<TWait> condition, string description, ITestInstruction<TResult> instruction, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TWait> | condition | Condition to wait on before executing |
string | description | Description of the responder which is constructed. |
ITestInstruction<TResult> | instruction | Instruction to execute after |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestResponder<TResult> | A test responder composed of |
Type Parameters
Name | Description |
---|---|
TWait | Result type of the wait condition. |
TResult | Result type of the instruction and the returned responder. |
ThenRespondWith<TWait, TResult>(ITestWaitCondition<TWait>, string, Func<TWait, ITestInstruction<TResult>>, string, string, int)
Constructs a test responder, which will wait for condition
to complete,
construct a test instruction using selector
,
and continue executing the returned instruction.
Will complete with a failure if the wait condition, selector, or constructed instruction
completes with a failure.
Declaration
[Pure]
public static ITestResponder<TResult> ThenRespondWith<TWait, TResult>(this ITestWaitCondition<TWait> condition, string description, Func<TWait, ITestInstruction<TResult>> selector, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
ITestWaitCondition<TWait> | condition | Condition to wait on before calling |
string | description | Description of the responder which is constructed. |
Func<TWait, ITestInstruction<TResult>> | selector | Function to construct the instruction part of the responder,
from the result of |
string | memberName | Caller member name provided by compiler. May be overridden for custom operators. |
string | sourceFilePath | Caller file path provided by compiler. May be overridden for custom operators. |
int | sourceLineNumber | Source line number provided by compiler. May be overridden for custom operators. |
Returns
Type | Description |
---|---|
ITestResponder<TResult> | A test responder composed of |
Type Parameters
Name | Description |
---|---|
TWait | Result type of the wait condition. |
TResult | Result type of the instruction and the returned responder. |