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

Also support codefix for .Within #670

Merged
merged 2 commits into from
Dec 31, 2023

Conversation

Laniusexcubitor
Copy link
Contributor

fixes #669

Copy link
Member

@manfred-brands manfred-brands left a comment

Choose a reason for hiding this comment

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

@Laniusexcubitor Thanks for your contribution.

I have made some tiny changes.
One to ensure that the test validates that the correct parameter is swapped.
The other because I'm pedantic and don't like abbreviated variable names.

public void Test()
{{
int expected = 5;
ClassicAssert.{classicAssertMethod}(expected, ↓1, 1);
Copy link
Member

Choose a reason for hiding this comment

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

It is never good to use two arguments with the same value as it doesn't proof that the correct argument is exchanged.
I have update the code to use double.Epsilon for the accuracy.

Comment on lines 160 to 166
if (invocationExpression.Expression is not MemberAccessExpressionSyntax mae)
{
memberAccessExpression = null;
return false;
}

memberAccessExpression = mae;
Copy link
Member

Choose a reason for hiding this comment

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

I simplified this a tiny bit. Mainly because I don't like shorthand names like mae

if (memberAccessExpression.Name.ToString() == NUnitFrameworkConstants.NameOfEqualConstraintWithin)
{
// e.g. Is.EqualTo(1).Within(1) or Is.Not.EqualTo(1).Within(1)
if (memberAccessExpression.Expression is not InvocationExpressionSyntax ies
Copy link
Member

Choose a reason for hiding this comment

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

Renamed ies into innerInnovationExpression

@manfred-brands manfred-brands merged commit 903a11f into nunit:master Dec 31, 2023
5 checks passed
@mikkelbu mikkelbu added this to the Release 4.0 milestone Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NUnit2007 does not provide codefix when .Within is used
3 participants