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

Implement NotBeEquivalent for objects (fixes #170) #1071

merged 2 commits into from Jun 4, 2019


Copy link

@lg2de lg2de commented Jun 1, 2019

Is this the right way?

Fixes #170

Copy link

jnyrup commented Jun 2, 2019

The implementation looks good to me, but I think we may need to be careful here.

BeEquivalentTo is heavily overloaded with 21 overloads whereas NotBeEquivalentTo has 7 overloads.
So adding overloads of NotBeEquivalentTo dripwise could change the resolved overload between releases.
Not saying that we shouldn't add these overloads, but I think it would be great if we could add them all in one release.

"AA".Should().BeEquivalentTo("BB"); // StringAssertions
"AA".Should().NotBeEquivalentTo("BB"); // does not exists

new object().Should().BeEquivalentTo(new object()); // Object Assertions
new object().Should().NotBeEquivalentTo(new object());  // does not exists, but would exist with this PR

new[] { "AA" }.Should().BeEquivalentTo(new[] { "BB" }); // StringCollectionAssertions
new[] { "AA" }.Should().NotBeEquivalentTo(new[] { "BB" });  // CollectionAssertions

new[] { 1 }.Should().BeEquivalentTo(new[] { 2 }); // GenericCollectionAssertions
new[] { 1 }.Should().NotBeEquivalentTo(new[] { 2 }); // CollectionAssertions

new Dictionary<int, int>().Should().BeEquivalentTo(1); // GenericDictionaryAssertions
new Dictionary<int, int>().Should().NotBeEquivalentTo(1); // does not exists

new ComparableOfInt(1).Should().BeEquivalentTo(1); // ComparableTypeAssertions
new ComparableOfInt(1).Should().NotBeEquivalentTo(1); // does not exists

Copy link
Contributor Author

lg2de commented Jun 2, 2019

Currently there are some overloads for NotEquivalent, some are missing.
With adding this one the Situation is not changed, but #170 is fixed.

Copy link

jnyrup commented Jun 2, 2019

Had a deeper look at the inheritance graphs.
Only StringCollectionAssertions and GenericCollectionAssertions inherits NotBeEquivalentTo from CollectionAssertions, otherwise it looks fine.

So no objections anyway 👍

Copy link

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can you also please update the docs?

Copy link
Contributor Author

lg2de commented Jun 2, 2019

I added small portion of documentation.
I did not find additional senseful references to BeEquivalentTo. So, I do not know where to have additional documentation for the new overload.

@dennisdoomen dennisdoomen merged commit 3d6ac5a into fluentassertions:master Jun 4, 2019
@lg2de lg2de deleted the NotBeEquivalent branch June 9, 2019 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

3 participants