efcore icon indicating copy to clipboard operation
efcore copied to clipboard

ModelBuilder tests failing on PG because of problematic set comparison

Open roji opened this issue 1 year ago • 4 comments

As part of syncing EFCore.PG for 9.0.0-preview.1, I'm running into failures e.g. in Access_mode_can_be_overridden_at_entity_and_property_levels:

Assert.Equal() Failure: During comparison of two collections, GetHashCode was called, but only a comparison function was provided. This typically indicates trying to compare two sets with an item comparison function, which is not supported. For more information, see https://xunit.net/docs/hash-sets-vs-linear-containers
   at Microsoft.EntityFrameworkCore.TestUtilities.ModelAsserter.AssertEqual(IEnumerable`1 expectedForeignKey, IEnumerable`1 actualForeignKey, Boolean assertOrder, Boolean compareAnnotations) in /Users/roji/projects/efcore/test/EFCore.Specification.Tests/TestUtilities/ModelAsserter.cs:line 693

It seems that on that line, we're indeed comparing two SortedSets with the Assert.Equal() overload that's not supposed to be used with sets (docs). I'm not sure why this is failing on Npgsql but passing with SQL Server though.

/cc @AndriySvyryd

roji avatar Feb 11 '24 16:02 roji

Indeed, https://github.com/xunit/xunit/issues/2831#issuecomment-1841743496

You are probably using a newer xunit.

AndriySvyryd avatar Feb 12 '24 19:02 AndriySvyryd

Ah yeah, that makes sense, OK. I'll downgrade for now.

roji avatar Feb 12 '24 19:02 roji

Downgraded xunit back to 2.6.1 in https://github.com/npgsql/efcore.pg/pull/3094, the tests indeed now pass.

@AndriySvyryd if you want we can use this to track modifying our tests to react to the new xunit behavior?

roji avatar Feb 14 '24 13:02 roji

Note from triage: do it once we update to use .NET preview 1 in the build.

ajcvickers avatar Feb 16 '24 09:02 ajcvickers