What's the difference between Assert.AreNotEqual and Assert.AreNotSame?

前端 未结 6 2126
情书的邮戳
情书的邮戳 2020-12-24 10:33

In C#, what\'s the difference between

Assert.AreNotEqual

and

Assert.AreNotSame
6条回答
  •  悲哀的现实
    2020-12-24 10:58

    Isn't it so that AreNotEqual checks for the case where two objects are not equal in terms of Equals() method, whereas AreNotSame checks for the case where the two object references are not the same. So if x and y are two objects which are equal in terms of Equals() but have been separately allocated, AreNotEqual() would trigger failing assertion but the other not.

提交回复
热议问题