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
sourceStrategy<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
Returns
- Strategy<TResult>
Type Parameters
TSourceTResult
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
sourceStrategy<TSource>collectionSelectorFunc<TSource, Strategy<TCollection>>resultSelectorFunc<TSource, TCollection, TResult>
Returns
- Strategy<TResult>
Type Parameters
TSourceTCollectionTResult
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
Returns
- Strategy<TResult>
Type Parameters
TSourceTResult
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
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
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
Returns
- Strategy<(TFirst, TSecond)>
Type Parameters
TFirstTSecond
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
Returns
- Strategy<TResult>
Type Parameters
TFirstTSecondTResult