Skip to content

Commit

Permalink
Fix trivia for NUnit2046
Browse files Browse the repository at this point in the history
  • Loading branch information
verdie-g authored and manfred-brands committed Sep 18, 2024
1 parent 8b2e749 commit 859c2f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ public void TestMethod()
RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, code, fixedCode);
}

[TestCaseSource(nameof(NumericContraints))]
public void VerifyLengthWithNewLine(string constraint)
{
var code = TestUtility.WrapMethodInClassNamespaceAndAddUsings($@"
public void TestMethod()
{{
var array = new int[] {{ 1 }};
Assert.That(↓array.Length,
Is.{constraint});
}}");
var fixedCode = TestUtility.WrapMethodInClassNamespaceAndAddUsings($@"
public void TestMethod()
{{
var array = new int[] {{ 1 }};
Assert.That(array,
Has.Length.{constraint});
}}");
RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, code, fixedCode);
}

[TestCaseSource(nameof(NumericContraints))]
public void VerifyCount(string constraint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ await IsCollectionType(context, actualExpression.Expression).ConfigureAwait(fals
var hasPropertyExpression = SyntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
SyntaxFactory.IdentifierName(NUnitFrameworkConstants.NameOfHas),
propertyName);
propertyName).WithTriviaFrom(innerConstraintExpression);

nodesToReplace.Add(innerConstraintExpression, hasPropertyExpression);

Expand Down

0 comments on commit 859c2f8

Please sign in to comment.