Class TerminatingStepFunction
A step function that represents background work which will eventually complete. Subclasses must define IsTerminalState to indicate when the work is done, and GetStepResults(IState) to define how the state transitions.
This is used for:
- Test execution: Polling continues until IsTerminalState returns true for all states
- Test generation: Unwinding continues until IsTerminalState returns true
For daemon/fire-and-forget step functions that never terminate, use BaseStepFunction instead.
For simple cases, use Create<TState>(Func<TState, bool>, Action<TState>, string) to create an async operation inline without defining a class.
public abstract class TerminatingStepFunction : BaseStepFunction, IStepFunction
- Inheritance
-
TerminatingStepFunction
- Implements
- Inherited Members
Properties
IsTerminalState
Returns true when this step function's background work is complete. The predicate is evaluated against the current state.
During polling: We keep polling until this returns true for all possible states. During unwinding: We keep applying step functions until this returns true.
public abstract Func<IState, bool> IsTerminalState { get; }
Property Value
Methods
ApplyInternal(IState)
Sealed implementation that handles the terminal check automatically. Only calls GetStepResults(IState) when the state is not terminal. When terminal, returns the current state unchanged to consume the step function (removing it from the state profile).
protected override sealed IList<StepResult> ApplyInternal(IState state)
Parameters
stateIState
Returns
GetStepResults(IState)
Implement this method to define the possible state transitions. This method is only called when IsTerminalState returns false.
For a single deterministic outcome, return a single StepResult. For non-deterministic outcomes, return multiple StepResults.
protected abstract IList<StepResult> GetStepResults(IState state)
Parameters
stateIStateThe current state (do not mutate directly; clone first).
Returns
- IList<StepResult>
The list of possible next states.