Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Equals() exist?

Description for Assert.Equals() from the MSDN Documentation: Do not use this method.

That's it, the full explanation. Uh.. ok, but then ... why is it there? Is it a deprecated method from an earlier version of the framework? Something that's supposed to be used only by other Microsoft Assemblies?

It just makes me want to use it all the more knowing I'm not supposed to. ;-)

Does anyone know?

like image 480
mhenry1384 Avatar asked Jan 28 '09 20:01

mhenry1384


People also ask

What is assert equal in C#?

AreEqual tests whether the two arguments are equal.

What is Assert IsTrue?

Tests whether the specified condition is true and throws an exception if the condition is false. IsTrue() Tests whether the specified condition is true and throws an exception if the condition is false.

Which annotation identifies the method that is called just once after the last test in TestClass in Mstest is executed?

@After annotation is used on a method containing java code to run after each test case.

What is the attribute required for a class to be unit tested using MS test?

Attributes used to identify test classes and methods Every test class must have the TestClass attribute, and every test method must have the TestMethod attribute.


2 Answers

.Equals is inherited from object. It's listed as "Do not use this method" so users won't confuse it with the AreEqual method.

like image 58
David Morton Avatar answered Sep 18 '22 12:09

David Morton


All objects in .NET derive from Object.

Object has a .Equals() method.

Apparently the .Equals() method for this particular object doesn't do anything useful, so the docs are warning you that it doesn't do anything useful.

like image 24
Ryan Avatar answered Sep 21 '22 12:09

Ryan