You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I think that's an interesting idea but we would need to properly design what we want to support or not. FluentAssertion has tons of options so it will require quite some time to match them all (if we want to). We just looked at xUnit and there are some cases that are strange at first look and that we would need to explore better before we start the implementation.
Summary
Add an
Assert.AreEquivalent
method that performs a deep compare on two objects, similar to for example the xUnitAssert.Equivalent
method or FluentAssertion'sactual.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.The text was updated successfully, but these errors were encountered: