• Home
  • .NET
  • Unity
  • Godot
  • Design Overview
  • API Documentation
  • Changelog
  • GitHub
Show / Hide Table of Contents
  • Responsible
    • BddExtensions
    • IExternalResultSource
    • IFailureListener
    • IGlobalContextProvider
    • IOptionalTestResponder
    • ITestInstruction<T>
    • ITestOperation<T>
    • ITestResponder<T>
    • ITestScheduler
    • ITestWaitCondition<T>
    • LinqSupport
    • OptionalTestResponder
    • RepetitionLimitExceededException
    • Responsibly
    • TestFailureException
    • TestInstruction
    • TestInstructionExecutor
    • TestInstructionExecutor.StateNotificationCallback
    • TestOperationState
    • TestResponder
    • TestWaitCondition
  • Responsible.Bdd
    • IBddStep
    • Keywords
    • ScenarioBuilder
  • Responsible.Context
    • RunContext
  • Responsible.Docs
    • Inherit
  • Responsible.State
    • ITestOperationState
    • ITestOperationState<T>
    • StateStringBuilder
    • TestOperationStateTransition
    • TestOperationStatus
  • Responsible.Unity
    • TestOperationYieldInstruction<T>
    • UnhandledLogMessageException
    • UnityErrorLogInterceptor
    • UnityFailureListener
    • UnityTestInstructionExecutor
    • UnityTestScheduler
  • Responsible.Utilities
    • IMultipleTaskAwaiter<T>
    • IMultipleTaskSource<T>
    • IndentedStringBuilder<T>
    • RetryingPoller

Class TestResponder

Contains extension methods on ITestResponder<T>.

Inheritance
object
TestResponder
Namespace: Responsible
Assembly: Responsible.dll
Syntax
public static class TestResponder

Methods

BoxResult<T>(ITestResponder<T>)

Converts a test responder returning a value type into one returning the same value boxed into object. Can be useful for example in conjunction with RespondToAllOf<T>(params ITestResponder<T>[])

Declaration
[Pure]
public static ITestResponder<object> BoxResult<T>(this ITestResponder<T> responder) where T : struct
Parameters
Type Name Description
ITestResponder<T> responder

Test responder to wrap.

Returns
Type Description
ITestResponder<object>

A test responder which behaves otherwise identically to responder, but returns its result as a boxed object.

Type Parameters
Name Description
T

Return type of the responder to convert.

ExpectWithinSeconds<T>(ITestResponder<T>, double, string, string, int)

Constructs a test instruction, which will expect the provided responder to start responding within the provided timeout, and then continue executing the instruction of the responder. 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 ITestResponder<T> responder, double timeoutSeconds, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type Name Description
ITestResponder<T> responder

Responder to apply the timeout to.

double timeoutSeconds

Timeout for the responder to start responding, 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 responder, or a failure, if either the timeout is met or the responder otherwise fails.

Type Parameters
Name Description
T

Result type of the responder and the returned test instruction.

Remarks

The timeout for the complete operation will be the sum of the given timeout and the timeout of the instruction part of the responder.

Optionally<T>(ITestResponder<T>)

Converts a test responder to an optional test responder. An alias for RespondToAnyOf<T>(params ITestResponder<T>[]) with a single argument.

Declaration
[Pure]
public static IOptionalTestResponder Optionally<T>(this ITestResponder<T> responder)
Parameters
Type Name Description
ITestResponder<T> responder

Responder to convert to an optional responder.

Returns
Type Description
IOptionalTestResponder

An optional responder, which optionally responds to responder.

Type Parameters
Name Description
T

Result type of the responder, which is discarded by the returned optional responder.

Repeatedly<T>(ITestResponder<T>, int, string, string, int)

Converts a test responder to an optional test responder which repeatedly executes the responder, zero or more times.

Declaration
[Pure]
public static IOptionalTestResponder Repeatedly<T>(this ITestResponder<T> respondTo, int maximumRepeatCount, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type Name Description
ITestResponder<T> respondTo

Responder to convert to a repeated responder.

int maximumRepeatCount

Maximum number of times this responder is allowed to be executed. If this count is exceeded, the operation will fail.

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
IOptionalTestResponder

An optional responder, which repeatedly responds to respondTo.

Type Parameters
Name Description
T

Result type of the responder, which is discarded by the returned optional responder.

Remarks

Unless this is the intended behaviour, make sure that the responder is not synchronously ready to execute after finishing, as otherwise it will execute again in the same frame. The maximumRepeatCount parameter is non-optional, in order to bail out of these situations faster, as timeouts do not apply within a single frame (the timeout mechanism might be improved later, but is currently not trivial to do).

Select<T1, T2>(ITestResponder<T1>, Func<T1, T2>, string, string, int)

Applies a selector to the result of a test responder when the responder completes, transforming the result type to another type.

Declaration
[Pure]
public static ITestResponder<T2> Select<T1, T2>(this ITestResponder<T1> responder, Func<T1, T2> selector, string memberName = "", string sourceFilePath = "", int sourceLineNumber = 0)
Parameters
Type Name Description
ITestResponder<T1> responder

A test responder to apply the selector to.

Func<T1, T2> selector

A function to apply to the result of the responder.

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<T2>

A test responder whose result is the result of invoking selector on the result of responder.

Type Parameters
Name Description
T1

Return type of the initial responder.

T2

Return type of the selector and the returned responder.

In this article
Back to top Generated by DocFX