Table of Contents

Class StrategyExtensions

Namespace
Conjecture.Core
Assembly
Conjecture.Core.dll

LINQ-style extension methods for composing strategies.

public static class StrategyExtensions
Inheritance
StrategyExtensions
Inherited Members

Methods

OrNull<T>(Strategy<T>)

Wraps the strategy so it may also produce null, with ~10% null probability.

public static Strategy<T?> OrNull<T>(this Strategy<T> source) where T : struct

Parameters

source Strategy<T>

Returns

Strategy<T?>

Type Parameters

T

SelectMany<TSource, TResult>(Strategy<TSource>, Func<TSource, Strategy<TResult>>)

Projects each generated value to a strategy and flattens the result.

public static Strategy<TResult> SelectMany<TSource, TResult>(this Strategy<TSource> source, Func<TSource, Strategy<TResult>> selector)

Parameters

source Strategy<TSource>
selector Func<TSource, Strategy<TResult>>

Returns

Strategy<TResult>

Type Parameters

TSource
TResult

SelectMany<TSource, TCollection, TResult>(Strategy<TSource>, Func<TSource, Strategy<TCollection>>, Func<TSource, TCollection, TResult>)

Projects each generated value to a strategy, flattens, and applies a result selector (enables C# query syntax).

public static Strategy<TResult> SelectMany<TSource, TCollection, TResult>(this Strategy<TSource> source, Func<TSource, Strategy<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)

Parameters

source Strategy<TSource>
collectionSelector Func<TSource, Strategy<TCollection>>
resultSelector Func<TSource, TCollection, TResult>

Returns

Strategy<TResult>

Type Parameters

TSource
TCollection
TResult

Select<TSource, TResult>(Strategy<TSource>, Func<TSource, TResult>)

Projects each generated value through selector.

public static Strategy<TResult> Select<TSource, TResult>(this Strategy<TSource> source, Func<TSource, TResult> selector)

Parameters

source Strategy<TSource>
selector Func<TSource, TResult>

Returns

Strategy<TResult>

Type Parameters

TSource
TResult

Where<T>(Strategy<T>, Func<T, bool>)

Filters generated values to those satisfying predicate.

public static Strategy<T> Where<T>(this Strategy<T> source, Func<T, bool> predicate)

Parameters

source Strategy<T>
predicate Func<T, bool>

Returns

Strategy<T>

Type Parameters

T

WithLabel<T>(Strategy<T>, string)

Annotates the strategy with a label used in counterexample output.

public static Strategy<T> WithLabel<T>(this Strategy<T> source, string label)

Parameters

source Strategy<T>
label string

Returns

Strategy<T>

Type Parameters

T

Zip<TFirst, TSecond>(Strategy<TFirst>, Strategy<TSecond>)

Combines two strategies into a strategy of tuples.

public static Strategy<(TFirst, TSecond)> Zip<TFirst, TSecond>(this Strategy<TFirst> first, Strategy<TSecond> second)

Parameters

first Strategy<TFirst>
second Strategy<TSecond>

Returns

Strategy<(TFirst, TSecond)>

Type Parameters

TFirst
TSecond

Zip<TFirst, TSecond, TResult>(Strategy<TFirst>, Strategy<TSecond>, Func<TFirst, TSecond, TResult>)

Combines two strategies using a result selector.

public static Strategy<TResult> Zip<TFirst, TSecond, TResult>(this Strategy<TFirst> first, Strategy<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)

Parameters

first Strategy<TFirst>
second Strategy<TSecond>
resultSelector Func<TFirst, TSecond, TResult>

Returns

Strategy<TResult>

Type Parameters

TFirst
TSecond
TResult