nunit/nunit.analyzers

[bug] Code fix for NUnit2005 does not correctly fix Assert.AreEqual if the third argument is not the delta

Bartleby2718 opened this issue · 4 comments

Currently,

    [Test]
    public void TestMethod()
    {
        Assert.AreEqual(delta: 0.0000001d, actual: 3d, expected: 2d);
    }

is transformed into

    [Test]
    public void TestMethod()
    {
        Assert.That(actual: 3d, Is.EqualTo(delta: 0.0000001d).Within(2d));
    }

#716 fixes the Is.EqualTo part, but not the Within part. This issue is about the Within part.

I can re-target Bartleby2718#1 once #716 is merged.

It seems like accessing expected or actual by index (e.g. arguments[0]) is prevalent, but I'm not sure whether you want to file an issue for everything or fix everything in one PR.

  • If you file an issue for each *CodeFix file, that's going to be dozens of similar GitHub issues.
  • If you file one issue for everything, the PR is going to be too big, making it harder to review.

@Bartleby2718 I think one PR to fix all ClassicModelAssertUsage CodeFixes to be 'named parameter' would be the best. It allows us to come up with a more consistent design instead of 24 similar PRs with potential lot of duplication.

Closing in favor of #712