On why there is no Assert.AreEqual(T t1, T t2) where T: IEquatable – via Stack Overflow
Posted by jpluimers on 2015/09/08
Assert.AreEqual<T>(T t1, T t2) where T: IEquatable<T>
Interesting. And I need to give some thought because when calling Assert.AreEqual<T1, T2>(T1 object1, T2 object2) where T1 does not equal T2 will map to Assert.AreEqual(object, object) without compile time warning.
Assert.AreEqual(object, object) ultimately calls Assert.AreEqual<T>(T, T, String, Object[]) which calls Object.Equals(object, object) failing only at run-time.
This has bitten me too many times.
I wonder what NUnit provides here; will look into that later.
–jeroen
Leave a Reply