Default configurations
Last updated
Last updated
AutoFixture comes with a set of default builders so that most common scenarios are supported out-of-the-box.
These builders can be overridden with ad-hoc customizations or when building an anonymous variable.
The default builder for numbers is the .
It supports the following types: Byte
, Decimal
, Double
, Int16
, Int32
, Int64
, SByte
, Single
, UInt16
, UInt32
, UInt64
.
Unique numbers are generated randomly from the set [1, 255]
. Once these are used up they are then be generated from the set [256, 65 535]
. And finally from the set [65 536, 2 147 483 647]
.
When all numbers within the final set have been used AutoFixture will start again from the first set.
The default builder for chars is the .
It generates random characters from the printable ASCII character set (!
(33) to ~
(126)).
The default builder for strings is an instance of .
It returns randomly generated Guid
as string using the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
.
It generates a date and a time between 2 years prior and 2 years after the current date.
It returns all the values of the enumeration in order. When all values are used, it starts from the first value again.
AutoFixture has a built-in support for many collection types: Dictionary
, SortedDictionary
, SortedList
, Collection
, List
, HashSet
, SortedSet
, ObservableCollection
, and Array
.
Also, AutoFixture natively supports common collection interfaces like IDictionary
, IReadOnlyDictionary
, ICollection
, IReadOnlyCollection
, IList
, IReadOnlyList
, ISet
, and IEnumerable
. When requested, AutoFixture will return a type implementing the requested interface.
AutoFixture is able to generate out-of-the-box anonymous variables of both Tuple
and ValueTuple
types.
In the case of ValueTuple
, it also supports the simplified syntax.
The UriGenerator
delegates the scheme creation to a UriSchemeGenerator
configured to return http
by default.
This generator splits the email address into two parts that can be independently customized:
a EmailAddressLocalPart
, generated via a EmailAddressLocalPartGenerator
a DomainName
, generated via a DomainNameGenerator
For some types, the default configuration of AutoFixture is to return well-known values.
Here is a list of these cases:
IPAddress
is registered with the value IPAddress.Loopback
Encoding
is registered with the value Encoding.UTF8
CultureInfo
is registered with the value CultureInfo.InvariantCulture
The default builder for DateTime
is the .
The is the default builder for enumerations.
The default builder for Uri
is the .
The default builder for the MailAddress
type is the .