Table of Contents

Interface IStateMachine<TState, TCommand>

Namespace
Conjecture.Core
Assembly
Conjecture.Core.dll

Defines a stateful system under test for use with Conjecture's stateful testing engine.

public interface IStateMachine<TState, TCommand>

Type Parameters

TState

The type representing the system's state.

TCommand

The type representing a command that can be applied to the state.

Methods

Commands(TState)

Returns the commands that are applicable to the given state. An empty enumerable signals that no further commands can be applied.

IEnumerable<Strategy<TCommand>> Commands(TState state)

Parameters

state TState

The current state of the system.

Returns

IEnumerable<Strategy<TCommand>>

InitialState()

Returns the initial state of the system before any commands have been applied.

TState InitialState()

Returns

TState

Invariant(TState)

Asserts that state satisfies all invariants of the system. Throw any exception to signal a violation; return normally to indicate the state is valid.

void Invariant(TState state)

Parameters

state TState

The state to validate.

RunCommand(TState, TCommand)

Applies command to state and returns the resulting state. The original state must not be mutated; return a new state value instead.

TState RunCommand(TState state, TCommand command)

Parameters

state TState

The current state of the system.

command TCommand

The command to apply.

Returns

TState