Class ValueObjectCustomization
Namespace: AdCodicem.ValueObjects.AutoFixture
Assembly: AdCodicem.ValueObjects.AutoFixture.dll
Customizes an AutoFixture fixture so that every value object it creates is drawn from the rules its type declares: asked for directly, as its nullable form, or as a member of an object the fixture builds.
public sealed class ValueObjectCustomization : ICustomization
Inheritance
object ← ValueObjectCustomization
Implements
ICustomization
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Without it, AutoFixture calls the value object's Create with values of its own, longer than a declared
MaxLength, outside declared bounds, always the first known value of a closed set, and the creation fails or
passes by chance. With it, each value object is drawn by a
A registration of the fixture wins over the customization, whether it comes before or after it:
fixture.Register(() => EvenCode.Create(...)) is how a rule no schema carries, a checksum for one, is met in
AutoFixture's terms, as
A value object is found through ValueObjectRegistry.TryResolve, which describes a value object written by hand
the first time a fixture asks for it, and keeps that description. The customization is as thread-safe as the
Constructors
ValueObjectCustomization()
Initializes a new instance of the
public ValueObjectCustomization()
ValueObjectCustomization(ValueObjectSamplerOptions)
Initializes a new instance of the
public ValueObjectCustomization(ValueObjectSamplerOptions options)
Parameters
options ValueObjectSamplerOptions
How each value object is drawn, the generators of the rules no schema carries included.
Exceptions
options is null.
ValueObjectCustomization(ValueObjectSamplerOptions, Random)
Initializes a new instance of the
public ValueObjectCustomization(ValueObjectSamplerOptions options, Random random)
Parameters
options ValueObjectSamplerOptions
How each value object is drawn, the generators of the rules no schema carries included.
random Random
The source of randomness: a
Exceptions
options or random is null.
Methods
Customize(IFixture)
Adds to the fixture's customizations a specimen builder that answers the request for any value object type, or for its nullable type, with a value its rules accept.
public void Customize(IFixture fixture)
Parameters
fixture IFixture
The fixture to customize.
Exceptions
fixture is null.