I have a class, let's call it Foo
, that is a value type and hence overrides the Equals
/GetHashCode()
methods. In a separate test fixture, I want to assert that all the properties on Foo have been set properly, not just the properties used for equality. For this reason, my test assertion specifically uses the ShouldBeEquivalentTo
method, which the documentation suggests will consider two objects to be equivalent if "both object graphs have equally named properties with the same value, irrespective of the type of those objects."
However, it appears that ShouldBeEquivalentTo
invokes Foo.Equals
method, gets a true result and then proceeds to short-circuit the reflection based property matching that ShouldBeEquivalentTo
promises.
Is this expected behavior? If so, in inspecting the FA source, I saw no easy way to alter this behavior (IEquivalencyStep
is declared internal). Are there any other ways to around this?
Edit:
Dennis: Yes, the two objects I'm comparing are of the same type. To summarize, I have overridden Equals
on class Foo, but do not want FA to use this notion of equality for my unit tests.