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

Class ValueObjectSamplingException

Namespace: AdCodicem.ValueObjects.Testing.Data
Assembly: AdCodicem.ValueObjects.Testing.Data.dll

Thrown when a sampler cannot draw a value its type accepts: no candidate, drawn from its schema or from the generator registered for it, passed its rules, and it declares no example they accept.

public sealed class ValueObjectSamplingException : InvalidOperationException, ISerializable

Inheritance​

object ← Exception ← SystemException ← InvalidOperationException ← ValueObjectSamplingException

Implements​

ISerializable

Inherited Members​

Exception.GetBaseException(), Exception.GetType(), Exception.ToString(), Exception.Data, Exception.HelpLink, Exception.HResult, Exception.InnerException, Exception.Message, Exception.Source, Exception.StackTrace, Exception.TargetSite, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

It is a failure of test set-up, not a value refused at a boundary: it carries the code of the last refusal in , and nothing in , so ValueObjectErrors.TryGetCode does not read it as a refusal. Its message never holds a candidate value.

Its last sentence names the registration that gives the sampler a generator: the one to add, or the one whose values the type refused. A library drawing through the sampler writes it in its own terms by throwing it with its own registration.

Constructors​

ValueObjectSamplingException(Type, int, string?, string, bool)​

Initializes a new instance of the class.

public ValueObjectSamplingException(Type valueObjectType, int attempts, string? errorCode, string registration, bool fromGenerator = false)

Parameters​

valueObjectType Type

The value object no value could be drawn for.

attempts int

How many candidates were tried.

errorCode string?

The code of the rule that refused the last candidate, or null when none was drawn.

registration string

The registration of a generator, as code: options.Use<EvenCode, string>(random => ...).

fromGenerator bool

Whether the candidates came from a generator registered for the type, whose values its rules refused, rather than from its schema.

Exceptions​

ArgumentNullException

valueObjectType or registration is null.

Properties​

Attempts​

Gets how many candidates were tried.

public int Attempts { get; }

Property Value​

int

ErrorCode​

Gets the code of the rule that refused the last candidate, or null when no candidate was drawn at all: an underlying type the sampler draws no value of, with no known value, or lengths and a pattern no string it built could meet.

public string? ErrorCode { get; }

Property Value​

string?

FromGenerator​

Gets a value indicating whether the candidates came from a generator registered for the type rather than from its schema: the generator gives values the type refuses.

public bool FromGenerator { get; }

Property Value​

bool

ValueObjectType​

Gets the value object no value could be drawn for.

public Type ValueObjectType { get; }

Property Value​

Type