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

✨ Accept ISpecimentBuilder as value generator for With #1421

Closed
Kralizek opened this issue Nov 29, 2023 · 1 comment
Closed

✨ Accept ISpecimentBuilder as value generator for With #1421

Kralizek opened this issue Nov 29, 2023 · 1 comment
Labels
accepted Something that was accepted/approved for future release feature request An idea for a change, aimed at impoving quality of life
Milestone

Comments

@Kralizek
Copy link
Contributor

Description

I have to work with a class with a string property whose valid value is limited to few option (a missed enum).

I can use ElementsBuilder<string> to do so but the configuration is a bit cumbersome.

It would be great if With accepted ISpecimenBuilder directly.

Example

fixture.Customize<SomeProduct>(o => o
    .With(p => p.OperatingSystem, (IFixture f) => f.Build<string>().FromFactory(new ElementsBuilder<string>(new[]{"ios", "windows", "mac"})).Create())
);

could be written as

// IPostprocessComposer<T> With<TProperty, TInput>(Expression<Func<T, TProperty>> propertyPicker, ISpecimenBuilder valueFactory);
fixture.Customize<SomeProduct>(o => o
    .With(p => p.OperatingSystem, new ElementsBuilder<string>(new[]{"ios", "windows", "mac"}))
);
@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 added this to the future milestone Dec 5, 2023
@aivascu aivascu added accepted Something that was accepted/approved for future release and removed triage Something that's being investigated labels Feb 2, 2024
@aivascu aivascu modified the milestones: future, v5.0 Mar 10, 2024
@aivascu
Copy link
Member

aivascu commented Mar 10, 2024

Implemented in #1444. Available after AutoFixture v5.0.0-preview009

@aivascu aivascu closed this as completed Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Something that was accepted/approved for future release feature request An idea for a change, aimed at impoving quality of life
Projects
None yet
Development

No branches or pull requests

2 participants