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.
It supports the following types:
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.
It generates random characters from the printable ASCII character set (
It returns randomly generated
Guidas string using the format
It generates a date and a time between 2 years prior and 2 years after the current date.
var dateTime = fixture.Create<DateTime>();
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:
Also, AutoFixture natively supports common collection interfaces like
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
var tuple = fixture.Create<Tuple<string, int>>();
var valueTuple = fixture.Create<ValueTuple<string, int>>();
In the case of
ValueTuple, it also supports the simplified syntax.
var valueTuple = fixture.Create<(string, int)>();
UriGeneratordelegates the scheme creation to a
UriSchemeGeneratorconfigured to return
This generator splits the email address into two parts that can be independently customized:
EmailAddressLocalPart, generated via a
DomainName, generated via a
For some types, the default configuration of AutoFixture is to return well-known values.
Here is a list of these cases:
IPAddressis registered with the value
Encodingis registered with the value
CultureInfois registered with the value