You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently discovered this when I enabled the NUnit Analyzer in my test projects and discovered that the tests have always been passing when comparing two separate objects.
This behaviour for Uri is inconsistent: testUri.Equals(testString) returns true but testString.Equals(testUri) not.
And testUri == testString doesn't even compile.
Message:
Multiple failures or warnings in test:
1) AreEqual: string - Uri
Expected: "test"
But was: <test>
2) Uri, Is.EqualTo(string)
Expected: "test"
But was: <test>
For proper equality, the operation should be symmetric: a == b means b == a which is not the case for this overload.
Who am I to say that the Uri.Equals(string) interpretation shouldn't have been there.
If you try to
Assert
that aUri
is equal to astring
, the NUnit Analyzer shows an NUnit2021 error:But
Uri
must have some overloadedEquals()
logic that lets you compareUri
andstring
:https://dotnetfiddle.net/seNXx9
I recently discovered this when I enabled the NUnit Analyzer in my test projects and discovered that the tests have always been passing when comparing two separate objects.
I know this is similar to #186
The text was updated successfully, but these errors were encountered: