Skip to content
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

ShouldBeEquivalentTo flags two seemingly equivalent objects #973

Closed
2 tasks done
godrose opened this issue Nov 17, 2018 · 5 comments
Closed
2 tasks done

ShouldBeEquivalentTo flags two seemingly equivalent objects #973

godrose opened this issue Nov 17, 2018 · 5 comments
Assignees
Labels

Comments

@godrose
Copy link

godrose commented Nov 17, 2018

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

  • FA 5.5.1
  • .NET Framework 4.6.1
@jnyrup
Copy link
Member

jnyrup commented Nov 17, 2018

@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.

@godrose
Copy link
Author

godrose commented Nov 17, 2018

@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.

@jnyrup
Copy link
Member

jnyrup commented Nov 17, 2018

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

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);

@jnyrup
Copy link
Member

jnyrup commented Nov 18, 2018

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

In 5.4.2 BeEquivalentTo resolves to

NonGenericCollectionAssertions.BeEquivalentTo(IEnumerable expectation, string because = "", params object[] becauseArgs);

In 5.5.1 it resolves to

CollectionAssertions.BeEquivalentTo(params object[] expectations);

@dennisdoomen
Copy link
Member

Fixed in 5.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants