AutoFixture adhering to FluentValidation

Viewed 180

I'm currently learning using AutoFixture and can't figure out if there is a neat way to let AutoFixture generate a specimen that adheres the rules defined in my validator using FluentValidation.

Desired Solution

Let AutoFixture generate speciman following rules defined in validator.

Current Situation

AutoFixture generates random properties that violate the validation rules.

Question

Can AutoFixture create specimens adhering a AbstractValidator from FluentValidation?

1 Answers

Out of the box AutoFixture supports only DataAnnotations attributes as a means to generate models that would pass validation.

To my knowledge there is currently no glue library that would integrate AutoFixture with FluentValidation.

As a solution you might want to create customizations for your models that would adhere to the rules defined in your validators. Then compose the customizations in a way that would make sense for the tested scenario.

Related