StringLengthAttribute support in AutoFixture

By Nikos Baxevanis

Continuing the support of DataAnnotations as described here, there is now added support for the StringLengthAttribute class. Starting with version 2.4.0, when this attribute is applied on a data field it can specify the maximum length of characters that are allowed.

Let's take as an example the following type:

public class StringLengthValidatedType
    public string Property { get; set; }

Prior to version 2.4.0 if we request an anonymous instance from AutoFixture, by default we would get back an instance of the above type with it's Property containing a value similar to the one below.

Prior verion 2.4.0

However, after version 2.4.0 AutoFixture can handle requests with string length constraints through the StringLengthAttribute class by issuing a new request for a constrained string.

After verion 2.4.0

An automatically published release created from the latest successful build can be downloaded from here. The latest version is also live on NuGet.