MiHo
MiHo

Reputation: 190

AutoFixture adhering to FluentValidation

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?

Upvotes: 2

Views: 423

Answers (1)

Andrei Ivascu
Andrei Ivascu

Reputation: 1274

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.

Upvotes: 1

Related Questions