Skip to content

PgGenerators

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Creates the generators that PgPropertyRunner draws inputs from, like proptest’s built-in strategies.

public static class PgGenerators

Integers sometimes take their range’s limits so edge cases appear early, and they shrink toward zero, or toward the limit nearest zero when the range excludes it, preferring positive values. Text holds Unicode scalar values other than NUL, which PostgreSQL text cannot store, and favors ASCII letters and digits.

Inheritance: object

Produces arrays of generated elements.

public static PgGenerator<T[]> Array<T>(PgGenerator<T> element, int maxLength = 32)

Type parameters:

T

The element type.

Parameters:

element — PgGenerator<T>

The element generator.

maxLength — int

The most elements.

Returns: PgGenerator<T[]>

The generator, which shrinks toward fewer and simpler elements.

Exceptions:

Produces false or true, shrinking toward false.

public static PgGenerator<bool> Boolean()

Returns: PgGenerator<bool>

The generator.

Always produces the same value.

public static PgGenerator<T> Constant<T>(T value)

Type parameters:

T

The value type.

Parameters:

value — T

The value.

Returns: PgGenerator<T>

The generator.

Produces one of the supplied values, shrinking toward the first.

public static PgGenerator<T> Element<T>(params T[] values)

Type parameters:

T

The value type.

Parameters:

values — T[]

The candidates.

Returns: PgGenerator<T>

The generator.

Exceptions:

Produces any value of a binary floating-point type, such as double or float, including infinities, NaN, negative zero and subnormal values, shrinking toward small whole numbers.

public static PgGenerator<T> FloatingPoint<T>() where T : IBinaryFloatingPointIeee754<T>, IMinMaxValue<T>

Type parameters:

T

double, float or Half.

Returns: PgGenerator<T>

The generator.

Exceptions:

Produces SQL NULL as null for one value in eight, otherwise a generated reference.

public static PgGenerator<T?> NullableReference<T>(PgGenerator<T> value) where T : class

Type parameters:

T

The reference type.

Parameters:

value — PgGenerator<T>

The value generator.

Returns: PgGenerator<T>

The generator.

Produces SQL NULL as null for one value in eight, otherwise a generated value.

public static PgGenerator<T?> Nullable<T>(PgGenerator<T> value) where T : struct

Type parameters:

T

The value type.

Parameters:

value — PgGenerator<T>

The value generator.

Returns: PgGenerator<T?>

The generator.

Produces any value of an integer type, such as int, long or byte.

public static PgGenerator<T> Number<T>() where T : IBinaryInteger<T>, IMinMaxValue<T>

Type parameters:

T

The integer type, at most 64 bits wide.

Returns: PgGenerator<T>

The generator.

Exceptions:

Produces integers in an inclusive range.

public static PgGenerator<T> Number<T>(T minimum, T maximum) where T : IBinaryInteger<T>

Type parameters:

T

The integer type.

Parameters:

minimum — T

The smallest value.

maximum — T

The largest value.

Returns: PgGenerator<T>

The generator.

Exceptions:

Produces a value from one of the supplied generators, shrinking toward the first.

public static PgGenerator<T> OneOf<T>(params PgGenerator<T>[] generators)

Type parameters:

T

The value type.

Parameters:

generators — PgGenerator<T>[]

The alternatives.

Returns: PgGenerator<T>

The generator.

Exceptions:

Produces text of Unicode scalar values other than NUL.

public static PgGenerator<string> Text(int maxLength = 32)

Parameters:

maxLength — int

The most scalar values; text is at most twice as many UTF-16 characters.

Returns: PgGenerator<string>

The generator, which shrinks toward shorter text and simpler characters.

Exceptions: