Skip to content

BeInAscendingOrder() fails with ArgumentNullException #1803

@cobussmit74

Description

@cobussmit74

Description

BeInAscendingOrder fails when used with a propertyExpression parameter

Complete minimal example reproducing the issue

[Test]
public void When_testing_order_of_lists()
{
  var actual = new[] {1, 2, 3, 4};

  actual.Should().BeInAscendingOrder(x => x);
}

Expected behavior:

Should not fail.

Actual behavior:

Test fails with ArgumentNullException
Stack Trace:

System.ArgumentNullException : A member path cannot be null or empty (Parameter 'dottedPath')
   at FluentAssertions.Common.Guard.ThrowIfArgumentIsNullOrEmpty(String str, String paramName, String message)
   at FluentAssertions.Common.MemberPath..ctor(String dottedPath)
   at FluentAssertions.Common.ExpressionExtensions.GetMemberPath[TDeclaringType,TPropertyType](Expression`1 expression)
   at FluentAssertions.Collections.GenericCollectionAssertions`3.IsValidProperty[TSelector](Expression`1 propertyExpression, String because, Object[] becauseArgs)
   at FluentAssertions.Collections.GenericCollectionAssertions`3.BeOrderedBy[TSelector](Expression`1 propertyExpression, IComparer`1 comparer, SortOrder direction, String because, Object[] becauseArgs)
   at FluentAssertions.Collections.GenericCollectionAssertions`3.BeInAscendingOrder[TSelector](Expression`1 propertyExpression, IComparer`1 comparer, String because, Object[] becauseArgs)
   at FluentAssertions.Collections.GenericCollectionAssertions`3.BeInAscendingOrder[TSelector](Expression`1 propertyExpression, String because, Object[] becauseArgs)

Versions

  • Which version of Fluent Assertions are you using?

    • 6.5.0

Additional Information

Removing the propertyExpression parameter and just using .BeInAscendingOrder() works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions