Guest User

C# UnitTest - Assert.AreEqual() does not call Equals if the argument is null

a guest
Feb 26th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2.  
  3. class TestClass
  4. {
  5. public override bool Equals(object obj)
  6. {
  7. return true;
  8. }
  9. }
  10.  
  11. [TestMethod]
  12. public void TestMethod1()
  13. {
  14. TestClass t = new TestClass ();
  15. Assert.AreEqual (t, null); // fails
  16. Assert.IsTrue (t.Equals (null)); // passes
  17. }
Add Comment
Please, Sign In to add comment