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
Then, NUnit2010 flags the following assertions and proposes some fixes (as of NUnit.Analyzers 4.2.0):
// Assert.That(nullString, Is.EqualTo(null)); is proposed for the following two:
Assert.That(nullString isnull);
Assert.That(nullString==null);// Assert.That(nonNullString, Is.Not.EqualTo(null)); is proposed for the following two:
Assert.That(nonNullString is not null);
Assert.That(nonNullString!=null);// Assert.That(nullInt, Is.EqualTo(null)); is proposed for the following two:
Assert.That(nullInt isnull);
Assert.That(nullInt==null);// Assert.That(nonNullInt, Is.Not.EqualTo(null)); is proposed for the following two:
Assert.That(nonNullInt is not null);
Assert.That(nonNullInt!=null);
I don't know how Is.EqualTo is implemented under the hood, but I'm pretty sure Is.Null or Is.Not.Null should be used for either half or all of the fixes, depending on how Is.EqualTo works.
The text was updated successfully, but these errors were encountered:
manfred-brands
changed the title
[bug] NUnit2010 should provide a different suggestion for null comparison
[improvement] NUnit2010 should provide a different suggestion for null comparison
Jun 2, 2024
The actual generated code is correct, but indeed it could improve the code more by checking the actual argument tested and generated Is.Null for null and also Is.Zero for 0.
Suppose the following:
Then, NUnit2010 flags the following assertions and proposes some fixes (as of
NUnit.Analyzers
4.2.0):I don't know how
Is.EqualTo
is implemented under the hood, but I'm pretty sureIs.Null
orIs.Not.Null
should be used for either half or all of the fixes, depending on howIs.EqualTo
works.The text was updated successfully, but these errors were encountered: