diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs index c62d8eb..1c6dffd 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs @@ -556,6 +556,12 @@ public void CollectionShouldHaveCount_LengthShouldBe_TestNoAnalyzer(string asser [Implemented] public void CollectionShouldHaveCountLessOrEqualTo_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticCodeBlock(assertion, DiagnosticMetadata.CollectionShouldHaveCountLessOrEqualTo_CountShouldBeLessOrEqualTo); + [DataTestMethod] + [AssertionDiagnostic("(actual.Count() + 1).Should().BeLessOrEqualTo(k{0});")] + [AssertionDiagnostic("(actual.Count() + 1).Should().BeLessOrEqualTo(6{0});")] + [Implemented] + public void CollectionShouldHaveCountLessOrEqualTo_TestNoAnalyzer(string assertion) => DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(GenerateCode.GenericIListCodeBlockAssertion(assertion)); + [DataTestMethod] [AssertionCodeFix( oldAssertion: "actual.Count().Should().BeLessOrEqualTo(k{0});", diff --git a/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs b/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs index f03d444..985d91f 100644 --- a/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs +++ b/src/FluentAssertions.Analyzers.Tests/Tips/NumericTests.cs @@ -93,6 +93,11 @@ void verifyNoDiagnostic(string type) [Implemented] public void NumericShouldBeApproximately_TestAnalyzer(string assertion) => VerifyCSharpDiagnostic(assertion, DiagnosticMetadata.NumericShouldBeApproximately_MathAbsShouldBeLessOrEqualTo); + [DataTestMethod] + [AssertionDiagnostic("(Math.Abs(expected - actual) + 1).Should().BeLessOrEqualTo(delta{0});")] + [Implemented] + public void NumericShouldBeApproximately_TestNoAnalyzer(string assertion) => DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(GenerateCode.NumericAssertion(assertion, "double")); + [DataTestMethod] [AssertionCodeFix( oldAssertion: "Math.Abs(expected - actual).Should().BeLessOrEqualTo(delta{0});", diff --git a/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs b/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs index f11c3ad..41a39f8 100644 --- a/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs +++ b/src/FluentAssertions.Analyzers/Tips/FluentAssertionsAnalyzer.cs @@ -475,7 +475,7 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs return; case "BeLessOrEqualTo" when assertion.IsContainedInType(metadata.NumericAssertionsOfT2): { - if (invocation.TryGetFirstDescendent(out var invocationBeforeShould)) + if (invocation.TryGetSingleArgumentAs(out var invocationBeforeShould)) { switch (invocationBeforeShould.TargetMethod.Name) {