CheckExpectation Module
Builders and combinators for property-style expectations.
Functions and values
| Function or value |
Description
|
Full Usage:
CheckExpectation.andAlso a b
Parameters:
CheckExpectation<'Args, 'Actual, 'Expected>
-
The first required expectation.
b : CheckExpectation<'Args, 'Actual, 'Expected>
-
The second required expectation.
Returns: CheckExpectation<'Args, 'Actual, 'Expected>
A reusable expectation that succeeds only when both input expectations succeed.
|
Combines two expectations so that both must succeed.
|
Full Usage:
CheckExpectation.equalBy projection
Parameters:
'T -> 'Key
-
The projection applied to both successful values before comparison.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation that compares projected keys with F# equality. If either side throws,
the expectation falls back to exception-shape comparison and mismatch reporting.
|
Builds an equality expectation after projecting both tested and reference values.
Example
type Person =
{
Name: string
Age: int
}
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int |
Full Usage:
CheckExpectation.equalByKey projection expectedKey
Parameters:
'T -> 'Key
-
The projection applied to both successful values.
expectedKey : 'Key
-
The fixed projected key both the tested code and the reference must produce.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation for “both sides land on this key” scenarios, such as comparing records by
one field or normalized representation.
|
Builds an equality expectation that requires both projected values to equal one fixed key.
Example
module String
from Microsoft.FSharp.Core
val length: str: string -> int
Multiple items
val string: value: 'T -> string -------------------- type string = System.String |
Full Usage:
CheckExpectation.equalTo expected
Parameters:
'T
-
The fixed value both sides must produce.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation for fixed-value property checks that uses Diff.defaultOptions for
mismatch rendering.
|
Builds an expectation that requires both tested code and the reference to equal a fixed expected value.
|
Full Usage:
CheckExpectation.equalToReference
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation that succeeds when both sides return equal successful values or throw the
same exception type.
|
Builds an expectation that requires tested code and the reference to behave identically.
Example
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ... val sort: list: 'T list -> 'T list (requires comparison)
|
Full Usage:
CheckExpectation.equalToReferenceWithDiff diffOptions
Parameters:
DiffOptions
-
Diff settings used when the tested code and reference return different successful values.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation that compares tested code and reference behavior with custom diff rendering.
|
Builds an equality expectation against the reference implementation using the supplied diff options.
|
Full Usage:
CheckExpectation.equalToWithDiff diffOptions expected
Parameters:
DiffOptions
-
Diff settings used when rendering mismatches. Use Diff.defaultOptions for the standard
Testify explanation strategy, or create a custom DiffOptions value when you want different
truncation or structural-diff behavior.
expected : 'T
-
The fixed value both sides must produce.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation for fixed-value property checks with custom diff rendering.
|
Builds an expectation that requires both tested code and the reference to equal a fixed expected value.
|
Full Usage:
CheckExpectation.equalWith comparer
Parameters:
'T -> 'T -> bool
-
The custom equality relation. It receives the tested successful value first and the reference
successful value second.
Returns: CheckExpectation<'Args, 'T, 'T>
A reusable expectation that delegates successful-value comparison to comparer.
|
Builds an equality expectation using a custom comparer.
Example
type Person =
{
Name: string
Age: int
}
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int |
Full Usage:
CheckExpectation.isFalse
Returns: CheckExpectation<'Args, bool, bool>
A reusable bool expectation for “both sides are false”.
|
Builds a bool expectation that requires the tested code and reference to be
|
Full Usage:
CheckExpectation.isTrue
Returns: CheckExpectation<'Args, bool, bool>
A reusable bool expectation for “both sides are true”.
|
Builds a bool expectation that requires the tested code and reference to be
|
Full Usage:
CheckExpectation.orElse a b
Parameters:
CheckExpectation<'Args, 'Actual, 'Expected>
-
The first alternative expectation.
b : CheckExpectation<'Args, 'Actual, 'Expected>
-
The second alternative expectation.
Returns: CheckExpectation<'Args, 'Actual, 'Expected>
A reusable expectation that succeeds when either input expectation succeeds.
|
Combines two expectations so that either one may succeed.
|
Full Usage:
CheckExpectation.satisfyObservedWith description predicate
Parameters:
string
-
A short human-readable description of the relation.
predicate : 'Args -> Observed<'Actual> -> Observed<'Expected> -> bool
-
The predicate that receives generated arguments and both fully observed outcomes, including
exceptions.
Returns: CheckExpectation<'Args, 'Actual, 'Expected>
A reusable observed-outcome expectation.
|
Builds an expectation from a predicate over fully observed outcomes, including exceptions.
|
Full Usage:
CheckExpectation.satisfyWith description predicate
Parameters:
string
-
A short human-readable description of the relation.
predicate : 'Args -> 'Actual -> 'Expected -> bool
-
The predicate that receives generated arguments, the tested successful value, and the reference
successful value. It is only called when both sides returned successfully.
Returns: CheckExpectation<'Args, 'Actual, 'Expected>
A reusable successful-value expectation.
|
Builds an expectation from a predicate over successful values only.
|
Full Usage:
CheckExpectation.throwsSameExceptionType
Returns: CheckExpectation<'Args, 'Actual, 'Expected>
A reusable expectation for exception-shape comparisons. It succeeds only when both sides throw and
the thrown exception types match.
|
Builds an expectation that requires both implementations to throw the same exception type.
Example
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int |
testify