`AllBeEquivalentTo` works on enums but not on strings
See original GitHub issueDescription
AllBeEquivalentTo
works on enums but not on strings. This is very inconvenient
Complete minimal example reproducing the issue
E.g. testing the State
property of a collection of objects all have the same enum value I can write
someCollection.Select(x => x.State)
.Should()
.AllBeEquivalentTo(StateEnum.Inactive);
Changing field State
from StateEnum
to string
I had to rewrite my asserts to
someCollection.Select(x => x.State)
.Distinct()
.Should()
.BeEquivalentTo("Inactive");
which is less elegant than using AllBeEquivalentTo
Expected behavior:
be able to use AllBeEquivalentTo
with strings
Actual behavior:
compiler error
Versions
-
Which version of Fluent Assertions are you using? 5.10.3
-
Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.1. core 3.1
Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Associating Enums with string c# - Stack Overflow
Elegant code is typically described as simple, clean, terse with clear intent and optimally performant, I'm not seeing any of these traits ...
Read more >String Enums in C#: Everything You Need to Know
Since C# doesn't support enum with string value, in this blog post, we'll look at alternatives and examples that you can use in...
Read more >Enum.ToString Method (System)
Converts the value of this instance to its equivalent string representation.
Read more >Collections
A collection object in .NET is so versatile that the number of assertions on them require the same level of versatility. Most, if...
Read more >When are enums NOT a code smell?
When transmitting data enums are no code smell ... Strings may cause problems by variations in spelling and capitalisation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Very soon. I’m trying to fix the last bugs and have already prepared a blog post.
thanks