Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectArbitrary

Namespace: AdCodicem.ValueObjects.FsCheck
Assembly: AdCodicem.ValueObjects.FsCheck.dll

The FsCheck arbitrary of a value object: values its rules accept, drawn from the schema it declares, biased towards the edges it declares, and shrinking to values it accepts.

public static class ValueObjectArbitrary

Inheritance​

object ← ValueObjectArbitrary

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

FsCheck draws the seed of each value, which seeds the that draws it, so that a failing run replays from the seed FsCheck reports. One value in four is one of the type's boundaries (), its bounds, its lengths and its known values, since a property over a wide type lands on its edges by chance once in a blue moon; the size FsCheck passes is not read.

A counterexample shrinks through : towards the values the type declares, its minimum, its first known value and its example, then through FsCheck's own shrinker of the underlying value, keeping only what the type accepts as it is, its normalizer leaving it unchanged. FsCheck has a shrinker for the integers up to 64 bits, , , , , , , and ; a value object over another type, , , or for one, shrinks to its declared values alone. From a declared value, a shrink goes on only to the declared values ranked before it.

Nothing of the value object is read before the first draw: neither its schema nor its type initializer runs when the arbitrary is built or merged.

Methods​

For<TSelf, TValue>(ValueObjectSamplerOptions?)​

Gets the arbitrary of a value object: values its rules accept, one in four at its boundaries, shrunk to values it accepts.

public static Arbitrary<TSelf> For<TSelf, TValue>(ValueObjectSamplerOptions? options = null) where TSelf : struct, IValueObject<TSelf, TValue>

Parameters​

options ValueObjectSamplerOptions?

How each value is drawn, the generators of the rules no schema carries included, or null for the defaults.

Returns​

Arbitrary<TSelf>

The arbitrary, to merge into a map with MergeArb or to hand to Prop.ForAll.

Type Parameters​

TSelf

The value object.

TValue

Its underlying type.

Remarks​

A draw that finds no value the type accepts throws a , out of the property's check.