Skip to content

Conversation

@jnyrup
Copy link
Member

@jnyrup jnyrup commented Jan 23, 2021

New EnumAssertions to follow up #1375 and to solve #1204

Be() now expects an expectation of the same type of enum, which was an issue that gave false negatives, e.g. #1403.

More lightweight/relevant IntelliSense as it doesn't inherit assertion methods from ReferenceAssertions.

Before:
image

After:
image

I've excluded [Not]BeEquivalentTo(object) as all cases that I can think of are now covered by:

  • [Not]HaveSameValueAs
  • [Not]HaveSameNameAs
  • [Not]HaveValue(decimal)

One question that remains for me, it whether it is too confusing that HaveValue is both used in:

  • NullableEnumAssertions to assert if it is not null, and in
  • EnumAssertions to assert on the underlying numeric value.

cc: @lg2de

This fixes #1204
This fixes #1403

@jnyrup jnyrup marked this pull request as ready for review February 6, 2021 14:21
@jnyrup jnyrup linked an issue Feb 6, 2021 that may be closed by this pull request
@jnyrup jnyrup force-pushed the EnumAssertions branch 3 times, most recently from 9bba195 to bd3340e Compare February 8, 2021 17:55
@jnyrup jnyrup requested a review from dennisdoomen February 8, 2021 18:00
@jnyrup
Copy link
Member Author

jnyrup commented Feb 8, 2021

I'd especially like an extra eye on the negative statements, if they handle nulls as expected.
E.g. how null.Should().NotHaveFlag() should behave.

nav: "sidebar"
---

## Enums ##
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 You really did a great job here.

@jnyrup jnyrup merged commit b25ccc2 into fluentassertions:develop Feb 9, 2021
@jnyrup jnyrup deleted the EnumAssertions branch February 9, 2021 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum comparison does not work as expected Comparing enum and int

2 participants