fluentassertions / fluentassertions.analyzers

Analyzers based on the FluentAssertions best practices docs
https://www.fluentassertions.com/tips
MIT License
136 stars 21 forks source link

False positive for "Use `.Should().OnlyHaveUniqueItems()`" #299

Closed FantasyTeddy closed 7 months ago

FantasyTeddy commented 7 months ago

Description

The analysis rule FAA0001: Use .Should().OnlyHaveUniqueItems() is triggered for collections that are not actually the same:

// Arrange
var expected = new List<string> {"First"};

// Act
var actual = new List<int> {0};

// Assert
actual.Should().HaveSameCount(expected.Distinct());

Expected behavior:

This code should not trigger the rule about using .OnlyHaveUniqueItems(), since it has a different meaning (consider that expected is passed in, instead of actual).

Actual behavior:

The rule is triggered.

Versions

Meir017 commented 7 months ago

@FantasyTeddy Thanks for reporting this!