Table of Contents

Class ExpectedOutcome

Namespace
Microsoft.Accordant
Assembly
Accordant.Operations.dll

An expected outcome includes a response descriptor that can be used to verify whether the observed response from the system is valid or not, an update state as well as an optional step function that runs concurrently with the rest of the system.

public class ExpectedOutcome
Inheritance
ExpectedOutcome
Inherited Members

Constructors

ExpectedOutcome(ResponseValidator, IState, IStepFunction, Func<object>)

public ExpectedOutcome(ResponseValidator validator, IState updatedState, IStepFunction stepFunction, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedState IState
stepFunction IStepFunction
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, IState, Func<object, StepFunctionList>, Func<object>)

public ExpectedOutcome(ResponseValidator validator, IState updatedState, Func<object, StepFunctionList> stepFunctionGenerator, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedState IState
stepFunctionGenerator Func<object, StepFunctionList>
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, IState, Func<object>)

public ExpectedOutcome(ResponseValidator validator, IState updatedState, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedState IState
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, Func<object, IState, StateList>, IStepFunction, Func<object>)

public ExpectedOutcome(ResponseValidator validator, Func<object, IState, StateList> stateTransition, IStepFunction stepFunction, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
stateTransition Func<object, IState, StateList>
stepFunction IStepFunction
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, Func<object, IState, StateList>, Func<object, StepFunctionList>, Func<object>)

Primary constructor - all other constructors normalize to this form.

public ExpectedOutcome(ResponseValidator validator, Func<object, IState, StateList> nextStateGenerator, Func<object, StepFunctionList> nextStepFunctions, Func<object> mockResponseGenerator = null)

Parameters

validator ResponseValidator
nextStateGenerator Func<object, IState, StateList>
nextStepFunctions Func<object, StepFunctionList>
mockResponseGenerator Func<object>

ExpectedOutcome(ResponseValidator, Func<object, IState, StateList>, Func<object>)

public ExpectedOutcome(ResponseValidator validator, Func<object, IState, StateList> stateTransition, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
stateTransition Func<object, IState, StateList>
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, Func<object, StateList>, IStepFunction, Func<object>)

public ExpectedOutcome(ResponseValidator validator, Func<object, StateList> updatedStateGenerator, IStepFunction stepFunction, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedStateGenerator Func<object, StateList>
stepFunction IStepFunction
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, Func<object, StateList>, Func<object, StepFunctionList>, Func<object>)

public ExpectedOutcome(ResponseValidator validator, Func<object, StateList> updatedStateGenerator, Func<object, StepFunctionList> stepFunctionGenerator, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedStateGenerator Func<object, StateList>
stepFunctionGenerator Func<object, StepFunctionList>
mockResponse Func<object>

ExpectedOutcome(ResponseValidator, Func<object, StateList>, Func<object>)

public ExpectedOutcome(ResponseValidator validator, Func<object, StateList> updatedStateGenerator, Func<object> mockResponse = null)

Parameters

validator ResponseValidator
updatedStateGenerator Func<object, StateList>
mockResponse Func<object>

Properties

MockResponseGenerator

A function that returns a mock response for state exploration.

public Func<object> MockResponseGenerator { get; }

Property Value

Func<object>

NextStateGenerator

A function that computes the next state(s) given the response and current state.

public Func<object, IState, StateList> NextStateGenerator { get; }

Property Value

Func<object, IState, StateList>

NextStepFunctions

A function that computes step functions given the response. Returns empty list if no step functions are triggered.

public Func<object, StepFunctionList> NextStepFunctions { get; }

Property Value

Func<object, StepFunctionList>

Validator

The validator used to check whether the observed response satisfies the expected constraints or not.

public ResponseValidator Validator { get; }

Property Value

ResponseValidator

Methods

Explain(object)

Returns an explanation of why the observed response did not match this expected outcome.

public string Explain(object observedResponse)

Parameters

observedResponse object

Returns

string

Matches(object, IState)

This method validates whether the observed response matches the expectation. If the observed response is valid, it returns the next state(s) and step function(s) as a StateProfile.

public (bool, StateProfile) Matches(object observedResponse, IState currentState)

Parameters

observedResponse object

The response to validate.

currentState IState

The current state.

Returns

(bool, StateProfile)

A tuple of (isValid, stateProfile).

Satisfies(object)

Checks if the observed response satisfies this expected outcome without computing the next state.

public bool Satisfies(object observedResponse)

Parameters

observedResponse object

Returns

bool

Operators

implicit operator ExpectedOutcomes(ExpectedOutcome)

public static implicit operator ExpectedOutcomes(ExpectedOutcome expectedResult)

Parameters

expectedResult ExpectedOutcome

Returns

ExpectedOutcomes