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

Feature Request: enumValue.Should().BeDefined() #1884

Closed
aureole82 opened this issue Apr 7, 2022 · 3 comments · Fixed by #1888
Closed

Feature Request: enumValue.Should().BeDefined() #1884

aureole82 opened this issue Apr 7, 2022 · 3 comments · Fixed by #1888
Assignees
Labels
api-approved API was approved, it can be implemented feature

Comments

@aureole82
Copy link

aureole82 commented Apr 7, 2022

Can you add an extension for this:

// Act.
var dayOfWeek = (DayOfWeek)999;

// Assert.
dayOfWeek.Should().BeOneOf(Enum.GetValues<DayOfWeek>());
Enum.IsDefined(dayOfWeek).Should().BeTrue();
// suggested: dayOfWeek.Should().BeDefined();

I use FluentAssertions Version="6.5.1".

@jnyrup jnyrup added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Apr 7, 2022
@jnyrup jnyrup changed the title Feature Request: enumValue.Should().BeDefined() Feature Request: enumValue.Should().BeDefined() Apr 7, 2022
@jnyrup
Copy link
Member

jnyrup commented Apr 7, 2022

I can confirm that this is not present and agree that it would be a nice addition to EnumAssertions.

Here's a more formal proposal of the APIs to add.

EnumAssertions<TEnum, TAssertions>.BeDefined(string because = "", params object[] becauseArgs);
EnumAssertions<TEnum, TAssertions>.NotBeDefined(string because = "", params object[] becauseArgs);

@dennisdoomen
Copy link
Member

Agreed

@IT-VBFK
Copy link
Contributor

IT-VBFK commented Apr 13, 2022

If you don't mind.. I would take this..

IT-VBFK added a commit to IT-VBFK/fluentassertions that referenced this issue Apr 13, 2022
@dennisdoomen dennisdoomen added api-approved API was approved, it can be implemented enhancement and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Apr 14, 2022
IT-VBFK added a commit to IT-VBFK/fluentassertions that referenced this issue Apr 14, 2022
IT-VBFK added a commit to IT-VBFK/fluentassertions that referenced this issue Apr 15, 2022
@jnyrup jnyrup mentioned this issue Dec 5, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved, it can be implemented feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants