Skip to content

Commit

Permalink
NUnit 4.3 has more than one EqualConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
manfred-brands committed Dec 22, 2024
1 parent d73461a commit 6e77c26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ public void TestFullNameOfConstants((string Constant, Type Type) pair)
Assert.That(GetValue(pair.Constant), Is.EqualTo(pair.Type.FullName), pair.Constant);
}

[Test]
public void TestPrefixOfAllEqualConstraints()
{
Assert.That(NUnitFrameworkConstants.PrefixOfAllEqualToConstraints, Is.EqualTo("NUnit.Framework.Constraints.Equal"));
}

[Test]
public void NameOfAssertAreEqualParameters()
{
Expand Down
2 changes: 2 additions & 0 deletions src/nunit.analyzers/Constants/NUnitFrameworkConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public static class NUnitFrameworkConstants
public const string FullNameOfTestDelegate = "NUnit.Framework.TestDelegate";
public const string FullNameOfThrows = "NUnit.Framework.Throws";

public const string PrefixOfAllEqualToConstraints = "NUnit.Framework.Constraints.Equal";

public const string NameOfTestCaseAttribute = "TestCaseAttribute";
public const string NameOfTestCaseSourceAttribute = "TestCaseSourceAttribute";
public const string NameOfTestAttribute = "TestAttribute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ protected override void AnalyzeAssertInvocation(OperationAnalysisContext context
var constraintMethod = constraintPartExpression.GetConstraintMethod();

if (constraintMethod?.Name != NUnitFrameworkConstants.NameOfIsEqualTo
|| constraintMethod.ReturnType?.GetFullMetadataName() != NUnitFrameworkConstants.FullNameOfEqualToConstraint)
|| constraintMethod.ReturnType?.GetFullMetadataName().StartsWith(
NUnitFrameworkConstants.PrefixOfAllEqualToConstraints, StringComparison.Ordinal) != true)
{
continue;
}
Expand Down

0 comments on commit 6e77c26

Please sign in to comment.