Skip to content

Commit

Permalink
Improve coverage for CollectionMemberObjectInfo (#1983)
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Aug 28, 2022
1 parent f064e41 commit 0ac2e2c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Tests/FluentAssertions.Equivalency.Specs/CollectionSpecs.cs
Expand Up @@ -1404,6 +1404,32 @@ public void When_an_unordered_collection_must_be_strict_using_an_expression_it_s
"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*");
}

[Fact]
public void Can_force_strict_ordering_based_on_the_parent_type_of_an_unordered_collection()
{
// Arrange
var subject = new[]
{
new { Name = "John", UnorderedCollection = new[] { 1, 2, 3, 4, 5 } },
new { Name = "Jane", UnorderedCollection = new int[0] }
};

var expectation = new[]
{
new { Name = "John", UnorderedCollection = new[] { 5, 4, 3, 2, 1 } },
new { Name = "Jane", UnorderedCollection = new int[0] }
};

// Act
Action action = () => subject.Should().BeEquivalentTo(expectation, options => options
.WithStrictOrderingFor(oi => oi.ParentType == expectation[0].GetType()));

// Assert
action.Should().Throw<XunitException>()
.WithMessage(
"*Expected*[0].UnorderedCollection*5 item(s)*empty collection*");
}

[Fact]
public void
When_an_unordered_collection_must_be_strict_using_an_expression_and_order_is_reset_to_not_strict_it_should_not_throw()
Expand Down

0 comments on commit 0ac2e2c

Please sign in to comment.