What is the usage of Assert.Equals? [closed]

2019-02-21 09:08发布

问题:

I am working on Unit Testing for my current project and came across something odd. The .Net UnitTesting library has both Assert.Equals and Assert.AreEqual. The remarks for Assert.Equals say to use Assert.AreEqual to compare two objects, but gives no reason as to why to do so over Assert.Equals. Can somebody explain when you should use Assert.Equals in unit testing, if ever and the difference between Assert.Equals and Assert.AreEqual?

回答1:

Assert.Equals is just the Equals method inherited from object. It has nothing to do with unit testing, and in fact, has no use.


To be more precise, Assert.Equals is exactly the same as Object.Equals. Object.Equals has a use.

However, if you're using Assert.Equals, then you're probably confusing it with Assert.AreEqual, and you want to stop using it.