Fluent assertion - compare empty objects

0

I'm generating a C# solution using another project. The generated solution contains multiple classes and a unit test file for each class.

A unit test creates two instances of a class and compares them. For the comparison, I chose FluentAssertion (I tried other external comparators like ComareNetObjects, but it took too long on objects with large depth).

The instances are compared as following:

inst1.Should().BeEquivalentTo(inst2);

The problem is that some of the generated classes have no fields or properties. For those classes, the unit test creates two instances (with no members) and compares them. The equivalency check throws:

System.InvalidOperationException(0x80131509): No members were found for comparison. Please specify some members to include in the comparison or choose a more meaningful assertion.

I don't want to expand the generated classes only for the tests, nor check for each instance's properties.

Is there a way to customize this behavior in FluentAssertion?

c#
code-generation
fluent-assertions
asked on Stack Overflow Mar 2, 2021 by rotem agel • edited Mar 2, 2021 by rotem agel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0