-
Notifications
You must be signed in to change notification settings - Fork 733
Closed
Labels
Description
Description
Comparing collections, where the type contains a property with inner collection of a complex type throws System.InvalidOperationException : No members were found for comparison. Please specify some members to include in the comparison or choose a more meaningful assertion.. This works if the property is sub-collection of strings.
Complete minimal example reproducing the issue
using FluentAssertions;
using NUnit.Framework;
namespace Fluent.Collections.Bug.Example
{
public class FluentCollections
{
[Test]
public void Fails_with_complex_sub_collection()
{
var orig = new[] { new OuterWithObject { MyProperty = new[] { new Inner(), new Inner() } } };
orig.Should().BeEquivalentTo(new[] { new OuterWithObject { MyProperty = new[] { new Inner(), new Inner() } } });
}
[Test]
public void Works_with_simple_sub_collection()
{
var orig = new[] { new OuterWithSimple { MyProperty = new[] { "foo" } } };
orig.Should().BeEquivalentTo(new[] { new OuterWithSimple { MyProperty = new[] { "foo" } } });
}
}
public class Inner { }
public class OuterWithObject
{
public Inner[] MyProperty { get; set; }
}
public class OuterWithSimple
{
public string[] MyProperty { get; set; }
}
}Expected behavior:
Both tests to pass.
Actual behavior:
Fails_with_complex_sub_collection fails with InvalidOperationException.
Versions
- Fluent Assertions v6.1.0
- .NET runtime: .NET Core 5.0.
Additional Information
Nope.