Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ DataAnnotations support for specimen factories #1426

Open
1 task done
aivascu opened this issue Dec 4, 2023 · 0 comments
Open
1 task done

✨ DataAnnotations support for specimen factories #1426

aivascu opened this issue Dec 4, 2023 · 0 comments
Labels
feature request An idea for a change, aimed at impoving quality of life triage Something that's being investigated
Milestone

Comments

@aivascu
Copy link
Member

aivascu commented Dec 4, 2023

Description

Allow the use of .NET data annotation attributes to be used when specifying a factory function for a specimen.

Example

fixture.Customize<Version>(o => o
    .FromFactory(([Range(0, 2)] int major, [Range(0, 10)] int minor, [Range(0, 100)] int patch) =>
    {
        return new Version(major, minor, patch);
    }));
fixture.Customize<Version>(o => o.FromFactory(CreateVersion)));

static Version CreateVersion([Range(0, 2)] int major, [Range(0, 10)] int minor, [Range(0, 100)] int patch)
{
    return new Version(major, minor, patch);
}

Tasks

  • Confirmed feature idea with maintainers in support forums

More Information

Currently the FromFactory method does not use the usual AutoFixture pipeline, but rather uses the delegate directly to create the new specimen.
Must investigate whether it is viable to allow AutoFixture to generate values and what implications might, changing the implementation, have.

@aivascu aivascu added feature request An idea for a change, aimed at impoving quality of life triage Something that's being investigated labels Dec 4, 2023
@aivascu aivascu changed the title ✨ Use DataAnnotations support for specimen factories ✨ DataAnnotations support for specimen factories Dec 4, 2023
@aivascu aivascu added this to the future milestone Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request An idea for a change, aimed at impoving quality of life triage Something that's being investigated
Projects
None yet
Development

No branches or pull requests

1 participant