-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Analyzer incorrectly recommends ContainsSingle for HaveCount(1).And.Contains() #96
Labels
Comments
@AquilaSands is this an actual use-case? collection.Should().ContainSingle().Which.Should().Be(1); |
It was an actual use case for me but I agree the |
@AquilaSands I think so. I'll take a look |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Analyzer incorrectly recommends
ContainsSingle()
forHaveCount(1).And.Contains(predicate)
but looking at the tests for ContaiansSingle they are not equivalent as shown by this test https://github.com/fluentassertions/fluentassertions/blob/501cf353ecc872154fae54960ee1b692851bfb8a/Tests/FluentAssertions.Specs/Collections/GenericCollectionAssertionsSpecs.cs#L302-L314 which passes when a collection has multiple elements with only one matching the predicate.Complete minimal example reproducing the issue
Complete means the code snippet can be copied into a unit test method in a fresh C# project and run.
Minimal means it is stripped from code not related to reproducing the issue.
Expected behavior:
No analyzer recommendation
Actual behavior:
Analyzer recommends using ContainsSingle
Versions
Fluent Assertions 0.11.4
.Net 5
The text was updated successfully, but these errors were encountered: