Fluentassertions: ShouldBeEquivalentTo flags two seemingly equivalent objects

Created on 17 Nov 2018  路  5Comments  路  Source: fluentassertions/fluentassertions

Description

Version 5.5.1 fails existing test - used to to work in 5.4.2

Complete minimal example reproducing the issue

Checkout the following repo: https://github.com/LogoFX/logofx-client-mvvm-viewmodel
Run the Unit tests - all tests are green
Upgrade to 5.5.1
Run the Unit tests - now some are red.

Expected behavior:

Tests remain green

Actual behavior:

Some tests are red

Versions

  • [x] FA 5.5.1
  • [x] .NET Framework 4.6.1
bug

All 5 comments

@godrose At least copy the source of the failing test in here together with the failure message you're seeing.
If you're like to see this fixed or explained faster, please provide a Minimal Complete Verifiable Example.

@jnyrup Thanks for the reply.
Please see whether this example is more suitable for you
https://github.com/godrose/FailingTest

The tests fail with the following messages:
FluentAssertions.Execution.AssertionFailedException Expected args.OldItems to be {System.Object (HashCode=18961937)}, but found {System.Object (HashCode=18961937)}. FluentAssertions.Execution.AssertionFailedException Expected args.OldItems to be {System.Object (HashCode=17043416)}, but found {System.Object (HashCode=17043416)}. FluentAssertions.Execution.AssertionFailedException Expected args.NewItems to be {System.Object (HashCode=45523402), System.Object (HashCode=35287174)}, but found {System.Object (HashCode=45523402), System.Object (HashCode=35287174)}.

Using previous version (5.4.2) restores the green state of the tests.

I don't have time to look deeper into this today, but I reduced the test case to this:

```c#
object item = new object();
object[] array = new[] { item };
IList readOnlyList = ArrayList.ReadOnly(array);

// Works
readOnlyList[0].Should().BeEquivalentTo(array[0]);

// Fails
readOnlyList.Should().BeEquivalentTo(array);
```

@dennisdoomen If you haven't already located it, git bisect marks b3b0245a56d1808b68d6fdbbf0ce95073e93d06a as the commit that changed behavior.

In 5.4.2 BeEquivalentTo resolves to
```c#
NonGenericCollectionAssertions.BeEquivalentTo(IEnumerable expectation, string because = "", params object[] becauseArgs);


In 5.5.1 it resolves to
```c#
CollectionAssertions.BeEquivalentTo(params object[] expectations);

Fixed in 5.5.2

Was this page helpful?
0 / 5 - 0 ratings