I have a custom type Type that implement IEquatable(Type).
Then I new up two instances of the type, none of them are Null
Assert.IsTrue(obj1.equals(obj2)) //Success
Assert.AreEqual(obj1, obj2) //False
Assert.AreEqual(Type)(obj1, obj2) //False
The first one hits my equals, the second one hits the ToString()
Any suggestions?
update
some code to illustrate: http://pastebin.com/1uecrfeW
more update
If I have to override the base equals, even if a better (generic) equals is available, then what’s the use of implementing IEquals(T)?
My guess is that it’s actually hitting
Equals(object)instead ofEquals(T). If you haven’t overriddenEquals(object)then it’s probably failing the assertion, which then usesToStringto create a useful failure message.If you could show a short but complete program which demonstrates the problem (including which
Assertmethod you’re calling – NUnit? Something else?) that would help.