JustDummies

Juste des dummies, mais redoutablement efficaces.

API v1.0.0-preview.6

Sections de l'API

Collections

Tableaux, listes, séquences, ensembles et dictionnaires, chacun construit sur un générateur pour ses éléments.

Les signatures et les commentaires de documentation ci-dessous restent en anglais sur toutes les pages, dans toutes les locales : ils sont lus directement dans les paquets publiés, et non écrits pour ce site.

sealed class

AnyArray<T>

A fluent generator of arbitrary array (T[]) values over an element generator. Shares the collection constraint surface (AnyCollection) — count bounds and contained values — and adds Distinct to require pairwise-distinct elements.

public sealed class AnyArray<T>
Hérite de
AnyCollection<T, T[], AnyArray<T>>
Implémente
IAny<T[]>

Construit via

static AnyArray<T?> Any.ArrayOf<T>(IAny<T?> item)Starts an arbitrary array (T[]) generator over item — same constraint surface as ListOf, producing an array.

Méthodes

AnyArray<T?> Distinct()Requires the elements to be pairwise distinct (default equality).
AnyArray<T?> Distinct(IEqualityComparer<T?> comparer)Requires the elements to be pairwise distinct under comparer.

abstract class

AnyCollection<TItem, TResult, TSelf>

The shared fluent surface of the collection generators. Every collection — a AnyList, an AnyArray, an AnySequence or an AnySet — carries a count and, optionally, values it must contain; the concrete generators add only how the elements are shaped (a set is always distinct) and what type Generate returns.

public abstract class AnyCollection<TItem, TResult, TSelf> where TSelf : AnyCollection<TItem, TResult, TSelf>
Implémente
IAny<TResult>

Méthodes

TSelf NonEmpty()Requires at least one element.
TSelf Empty()Fixes the collection to no elements.
TSelf WithCount(int count)Fixes the exact number of elements. Declared once per generator.
TSelf WithMinCount(int count)Requires at least count elements.
TSelf WithMaxCount(int count)Requires at most count elements, and steers the draw: the range becomes [minimum, count], so the bound you write is the bound you get (ADR-0076).
TSelf WithCountBetween(int minimum, int maximum)Requires a number of elements within the inclusive range [minimum, maximum], and draws across it.
TSelf Containing(TItem? value)Requires the collection to contain value. May be declared several times; each required value takes one element's room. In a distinct collection the required values must themselves be distinct.
TSelf ContainingAny(IAny<TItem?> generator)Requires the collection to contain a value drawn from generator at generation time — useful to force a particular shape of element into an otherwise arbitrary collection. Named apart from Containing to keep the two cases legible: Containing pins a concrete value known now, whereas this method draws one from a generator when the collection is built.
TResult? Generate()Produces one arbitrary value satisfying every constraint declared on this generator.

sealed class

AnyDictionary<TKey, TValue>

A fluent generator of arbitrary Dictionary values over a key generator and a value generator. The keys are distinct by nature — the count constraints bound the number of entries, and the key generator's domain gates feasibility exactly as it does for a AnySet: too small a key domain for the requested count fails eagerly with a ConflictingAnyConstraintException, a genuine shortfall surfaces at generation as an AnyGenerationException.

public sealed class AnyDictionary<TKey, TValue>
Implémente
IAny<Dictionary<TKey, TValue>>

Construit via

static AnyDictionary<TKey, TValue?> Any.DictionaryOf<TKey, TValue>(IAny<TKey> keys, IAny<TValue?> values)Starts an arbitrary Dictionary generator drawing keys from keys and values from values. Keys are distinct by nature, so the key generator's domain gates feasibility exactly as it does for SetOf.
static AnyDictionary<TKey, TValue?> Any.DictionaryOf<TKey, TValue>(IAny<TKey> keys, IAny<TValue?> values, IEqualityComparer<TKey> keyComparer)Starts an arbitrary Dictionary generator whose keys are deduplicated with keyComparer — the same comparer the resulting dictionary carries.

Méthodes

AnyDictionary<TKey, TValue?> NonEmpty()Requires at least one entry.
AnyDictionary<TKey, TValue?> Empty()Fixes the dictionary to no entries.
AnyDictionary<TKey, TValue?> WithCount(int count)Fixes the exact number of entries. Declared once per generator.
AnyDictionary<TKey, TValue?> WithMinCount(int count)Requires at least count entries.
AnyDictionary<TKey, TValue?> WithMaxCount(int count)Requires at most count entries.
AnyDictionary<TKey, TValue?> WithCountBetween(int minimum, int maximum)Requires a number of entries within the inclusive range [minimum, maximum].
AnyDictionary<TKey, TValue?> ContainingKey(TKey key)Requires the dictionary to contain an entry for key. May be declared several times; each required key takes one entry's room and the required keys must be distinct. A key outside the key generator's domain extends the effective cardinality exactly as AnySet's containment does, so an otherwise impossible entry count becomes reachable; the entry's value is generated like any other. Named ContainingKey rather than a bare Containing so the surface reads unambiguously on a dictionary, whose elements are key/value pairs.
AnyDictionary<TKey, TValue?> ContainingAnyKey(IAny<TKey> generator)Requires the dictionary to contain an entry whose key is drawn from generator at generation time — the key analogue of a collection's ContainingAny. Named apart from ContainingKey to keep the two cases legible: ContainingKey pins a concrete key known now, whereas this draws one from a generator when the dictionary is built. The drawn key takes one entry's room and its value is generated like any other.
AnyDictionary<TKey, TValue?> ContainingEntry(TKey key, TValue? value)Requires the dictionary to contain the entry key → value: the key is forced in exactly as ContainingKey does (inheriting the out-of-domain cardinality credit), and its value is pinned to value instead of being drawn from the value generator; the other entries stay arbitrary. Declaring two entries for the same key — or an entry and a ContainingKey for it — conflicts, since the keys must be distinct.
Dictionary<TKey, TValue?> Generate()Produces one arbitrary value satisfying every constraint declared on this generator.

sealed class

AnyList<T>

A fluent generator of arbitrary List values over an element generator. Shares the collection constraint surface (AnyCollection) — count bounds and contained values — and adds Distinct to require pairwise-distinct elements.

public sealed class AnyList<T>
Hérite de
AnyCollection<T, List<T>, AnyList<T>>
Implémente
IAny<List<T>>

Construit via

static AnyList<T?> Any.ListOf<T>(IAny<T?> item)Starts an arbitrary List generator over item. Unconstrained, it yields 0 to 8 elements; chain constraints to express what the surrounding code requires (NonEmpty(), WithCount(...), Distinct(), Containing(...)).

Méthodes

AnyList<T?> Distinct()Requires the elements to be pairwise distinct (default equality).
AnyList<T?> Distinct(IEqualityComparer<T?> comparer)Requires the elements to be pairwise distinct under comparer.

sealed class

AnySequence<T>

A fluent generator of arbitrary IEnumerable values over an element generator. The generated sequence is fully materialized: it never defers work, so enumerating it twice yields the same elements and never re-draws. Shares the collection constraint surface (AnyCollection) — count bounds and contained values — and adds Distinct to require pairwise-distinct elements.

public sealed class AnySequence<T>
Hérite de
AnyCollection<T, IEnumerable<T>, AnySequence<T>>
Implémente
IAny<IEnumerable<T>>

Construit via

static AnySequence<T?> Any.SequenceOf<T>(IAny<T?> item)Starts an arbitrary IEnumerable generator over item — same constraint surface as ListOf. The generated sequence is fully materialized, so it never re-draws when enumerated more than once.

Méthodes

AnySequence<T?> Distinct()Requires the elements to be pairwise distinct (default equality).
AnySequence<T?> Distinct(IEqualityComparer<T?> comparer)Requires the elements to be pairwise distinct under comparer.

sealed class

AnySet<T>

A fluent generator of arbitrary HashSet values over an element generator. A set is distinct by nature, so it carries the collection constraint surface (AnyCollection) — count bounds and contained values — without a Distinct() toggle. When the element generator advertises fewer distinct values than the requested count, the contradiction is caught eagerly with a ConflictingAnyConstraintException; otherwise a genuine shortfall surfaces at generation as an AnyGenerationException.

public sealed class AnySet<T>
Hérite de
AnyCollection<T, HashSet<T>, AnySet<T>>
Implémente
IAny<HashSet<T>>

Construit via

static AnySet<T?> Any.SetOf<T>(IAny<T?> item)Starts an arbitrary HashSet generator over item — distinct by nature. When the count exceeds the number of distinct values item can produce, the conflict is reported deterministically, before any element is drawn, and whichever order the chain was written in.
static AnySet<T?> Any.SetOf<T>(IAny<T?> item, IEqualityComparer<T?> comparer)Starts an arbitrary HashSet generator over item, deduplicating elements with comparer — the same comparer the resulting set carries.