-
Notifications
You must be signed in to change notification settings - Fork 728
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
If Tolerance is used a different comparer is used #4514
Comments
Would alternative 1 mean that if I create my own generic numeric type, I could not use Tolerance? |
How could it? Tolerance is passed to |
@manfred-brands What is the problem? This is an issue you have worked on, not me. I haven't looked at the code at all. I am just asking. |
NUnit doesn't know anything about your type and your type does know nothing about NUnit (I hope). If your type does not implement This issue is that if a type defined |
Note that option 1 is what NUnit 3.13 does. |
Whilst testing this out on a repository for work, I noticed we are inconsistent. However, should NUnit throw or should only NUnit.Analyzers warn? |
Do you mean that it should throw for string and stream too, which makes sense to me? Shouldn't that then be added to the PR ? |
Thanks, I will update the PR. |
Update the PR: Comparers determine if Tolerance is supported. Treatment is now consistent. |
As a result of the changes for #4436 and #4312, we are now in a situation that if a type implements
IEquatable<T>
and noTolerance
is specified, the type'sEqual(T)
method is called.Howevever, if
Tolerance
is specified, #4312 would throw anInvalidOperationException
After the change #4436, the
PropertiesComparer.Equals
method is called which callsEquals
on all properties, passing in the specifiedTolerance
.I wanted to align NUnit.Analyzer with the new
PropertiesComparer
, relaxing the {Within does not make sense rule](nunit/nunit.analyzers#617), when I stumbled over this odd behaviour.What behaviour do we want if a type implements
IEquatable<T>
(or overridesEquals(object)
) andTolerance
is specified:throw InvalidOperationException
?PropertiesComparer
changing the comparison used and using theTolerance
I'm leaning to 1. Which requires a minor change to NUnit4.
The text was updated successfully, but these errors were encountered: