Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve coverage for CollectionMemberObjectInfo #1983

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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