Description
Summary
Add an Assert.AreEquivalent
method that performs a deep compare on two objects, similar to for example the xUnit Assert.Equivalent
method or FluentAssertion's actual.Should().BeEquivalentTo(expected)
.
Background and Motivation
I'm trying to perform a deep compare of two objects based on the values of the properties, with the option to exclude certain properties.
I was using FluentAssertions
for this, but the latest version got a license change where it's now a paid license for commercial use. The only reason I was using this library is because MSTest doesn't provide a deep comparison option. Instead of having to switch to a different library, it would be useful to have this feature in MSTest itself like xUnit. Reducing the number of dependencies and having better feature parity with xUnit.
Proposed Feature
You can pass two objects into Assert.AreEquivalent(expected, actual)
and it will perform a comparison of all (public) fields and properties. It will raise an error if the value of a field/property doesn't match. Using a parameter, you can specify that certain properties should be ignored.
It would also be nice if it could perform a deep compare of the items in two collections. E.g. comparing the first item of each collection using the Assert.AreEquivalent
method.