Skip to content

Commit

Permalink
bugfix: improve CollectionShouldHaveCountLessThan_CountShouldBeLessTh…
Browse files Browse the repository at this point in the history
…an detection
  • Loading branch information
Meir017 committed Oct 24, 2024
1 parent d25e129 commit ebc959e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ public void CollectionShouldHaveCount_LengthShouldBe_TestNoAnalyzer(string asser
[Implemented]
public void CollectionShouldHaveCountLessThan_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticCodeBlock(assertion, DiagnosticMetadata.CollectionShouldHaveCountLessThan_CountShouldBeLessThan);

[DataTestMethod]
[AssertionDiagnostic("(actual.Count() + 1).Should().BeLessThan(k{0});")]
[AssertionDiagnostic("(actual.Count() + 1).Should().BeLessThan(6{0});")]
[Implemented]
public void CollectionShouldHaveCountLessThan_TestNoAnalyzer(string assertion) => DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(GenerateCode.GenericIListCodeBlockAssertion(assertion));

[DataTestMethod]
[AssertionCodeFix(
oldAssertion: "actual.Count().Should().BeLessThan(k{0});",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs
return;
case "BeLessThan" when assertion.IsContainedInType(metadata.NumericAssertionsOfT2):
{
if (invocation.TryGetFirstDescendent<IInvocationOperation>(out var invocationBeforeShould))
if (invocation.TryGetSingleArgumentAs<IInvocationOperation>(out var invocationBeforeShould))
{
switch (invocationBeforeShould.TargetMethod.Name)
{
Expand Down

0 comments on commit ebc959e

Please sign in to comment.