i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.
using Microsoft.VisualStudio.TestTools.UnitTesting; class TestClass { public override bool Equals(object obj) { return true; } } [TestMethod] public void TestMethod1() { TestClass t = new TestClass (); Assert.AreEqual (t, null); // fails Assert.IsTrue (t.Equals (null)); // passes }
I would expect this test to succeed. However, in Visual Studio 2008 / .NET 3.5 it fails. Is it intended to be like that or is it a bug?
Your TestClass violates the contract of
Object.Equals.Assert.AreEqualis relying on that contract, quite reasonably.The docs state (in the list of requirements):