diff --git a/src/nunit.analyzers.tests/IgnoreCaseUsage/IgnoreCaseUsageAnalyzerTests.cs b/src/nunit.analyzers.tests/IgnoreCaseUsage/IgnoreCaseUsageAnalyzerTests.cs index 4e823c5c..c558338f 100644 --- a/src/nunit.analyzers.tests/IgnoreCaseUsage/IgnoreCaseUsageAnalyzerTests.cs +++ b/src/nunit.analyzers.tests/IgnoreCaseUsage/IgnoreCaseUsageAnalyzerTests.cs @@ -12,6 +12,7 @@ public class IgnoreCaseUsageAnalyzerTests private static readonly ExpectedDiagnostic expectedDiagnostic = ExpectedDiagnostic.Create(AnalyzerIdentifiers.IgnoreCaseUsage); +#if !NUNIT4 [Test] public void AnalyzeWhenIgnoreCaseUsedForNonStringEqualToArgument() { @@ -20,6 +21,7 @@ public void AnalyzeWhenIgnoreCaseUsedForNonStringEqualToArgument() RoslynAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); } +#endif [TestCase(nameof(Is.EqualTo))] [TestCase(nameof(Is.EquivalentTo))] @@ -103,7 +105,7 @@ public void TestMethod() public void AnalyzeWhenIgnoreCaseUsedInConstraintCombinedByOperators() { var testCode = TestUtility.WrapInTestMethod(@" - Assert.That(1, Is.EqualTo(1).↓IgnoreCase | Is.EqualTo(true).↓IgnoreCase);"); + Assert.That(1 == 1, Is.EqualTo(false).↓IgnoreCase | Is.EqualTo(true).↓IgnoreCase);"); RoslynAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); } diff --git a/src/nunit.analyzers.tests/Operations/ConstraintExpressionPartTests.cs b/src/nunit.analyzers.tests/Operations/ConstraintExpressionPartTests.cs index dca1a2cb..25565d85 100644 --- a/src/nunit.analyzers.tests/Operations/ConstraintExpressionPartTests.cs +++ b/src/nunit.analyzers.tests/Operations/ConstraintExpressionPartTests.cs @@ -194,7 +194,7 @@ public async Task GetConstraintNameReturnsMethodName() [Test] public async Task GetHelperClassNameReturnsIdentifierName() { - var constraintPart = await CreateConstraintPart("Is.EqualTo(1).IgnoreCase").ConfigureAwait(false); + var constraintPart = await CreateConstraintPart("Is.EqualTo(\"X\").IgnoreCase").ConfigureAwait(false); Assert.That(constraintPart.HelperClass?.Name, Is.EqualTo("Is")); } diff --git a/src/nunit.analyzers.tests/WithinUsage/WithinUsageAnalyzerTests.cs b/src/nunit.analyzers.tests/WithinUsage/WithinUsageAnalyzerTests.cs index 6e0b7285..cccd9338 100644 --- a/src/nunit.analyzers.tests/WithinUsage/WithinUsageAnalyzerTests.cs +++ b/src/nunit.analyzers.tests/WithinUsage/WithinUsageAnalyzerTests.cs @@ -28,7 +28,9 @@ public void OneTimeSetUp() .WithMetadataReferences(existingReferences.Concat(MetadataReferences.Transitive(typeof(ImmutableArray<>)))); } +#if !NUNIT4 [TestCase(NUnitFrameworkConstants.NameOfIsEqualTo)] +#endif [TestCase(NUnitFrameworkConstants.NameOfIsLessThan)] [TestCase(NUnitFrameworkConstants.NameOfIsLessThanOrEqualTo)] [TestCase(NUnitFrameworkConstants.NameOfIsGreaterThan)] @@ -41,7 +43,9 @@ public void AnalyzeWhenAppliedToEqualityConstraintForStrings(string constraintNa RoslynAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); } +#if !NUNIT4 [TestCase(NUnitFrameworkConstants.NameOfIsEqualTo)] +#endif [TestCase(NUnitFrameworkConstants.NameOfIsLessThan)] [TestCase(NUnitFrameworkConstants.NameOfIsLessThanOrEqualTo)] [TestCase(NUnitFrameworkConstants.NameOfIsGreaterThan)] @@ -54,6 +58,7 @@ public void AnalyzeWhenAppliedToInvertedEqualityConstraintForStrings(string cons RoslynAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); } +#if !NUNIT4 [Test] public void AnalyzeWhenAppliedToNotEqualConstraintForStrings() { @@ -62,6 +67,7 @@ public void AnalyzeWhenAppliedToNotEqualConstraintForStrings() RoslynAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); } +#endif [Test] public void AnalyzeWhenAppliedToEqualityConstraintForArraysOfValidTypes() diff --git a/src/nunit.analyzers.tests/WithinUsage/WithinUsageCodeFixTests.cs b/src/nunit.analyzers.tests/WithinUsage/WithinUsageCodeFixTests.cs index 34def3b1..f2ea1b64 100644 --- a/src/nunit.analyzers.tests/WithinUsage/WithinUsageCodeFixTests.cs +++ b/src/nunit.analyzers.tests/WithinUsage/WithinUsageCodeFixTests.cs @@ -22,7 +22,9 @@ public void VerifyGetFixableDiagnosticIds() Assert.That(ids, Is.EquivalentTo(new[] { AnalyzerIdentifiers.WithinIncompatibleTypes })); } +#if !NUNIT4 [TestCase(NUnitFrameworkConstants.NameOfIsEqualTo)] +#endif [TestCase(NUnitFrameworkConstants.NameOfIsLessThan)] [TestCase(NUnitFrameworkConstants.NameOfIsLessThanOrEqualTo)] [TestCase(NUnitFrameworkConstants.NameOfIsGreaterThan)] @@ -39,7 +41,9 @@ public void FixesWithinUsageOnConstraintWithIncompatibleExpectedType(string cons fixTitle: WithinUsageCodeFix.RemoveWithinDescription); } +#if !NUNIT4 [TestCase(NUnitFrameworkConstants.NameOfIsEqualTo)] +#endif [TestCase(NUnitFrameworkConstants.NameOfIsLessThan)] [TestCase(NUnitFrameworkConstants.NameOfIsLessThanOrEqualTo)] [TestCase(NUnitFrameworkConstants.NameOfIsGreaterThan)] @@ -56,6 +60,7 @@ public void FixesWithinUsageOnInversedConstraintWithIncompatibleExpectedType(str fixTitle: WithinUsageCodeFix.RemoveWithinDescription); } +#if !NUNIT4 [Test] public void FixesWithinUsageOnConstraintWithIncompatibleExpectedTypeWithMessage() { @@ -81,5 +86,6 @@ public void FixesWithinUsageOnConstraintWithIncompatibleExpectedTypeWithMessageA RoslynAssert.CodeFix(analyzer, fix, expectedDiagnostic, code, fixedCode, fixTitle: WithinUsageCodeFix.RemoveWithinDescription); } +#endif } }