Wednesday 15 August 2012

How does Assert.AreEqual compare two objects in .net unit tests? -


I'm writing a unit test for some pure code.

I'm familiar with writing code like this:

  int expected = 10; Int real = multiplyByTwo (5); Extraordinary (Expected, real);   

It is logic that logic is integer, it is clear what the code has to do.

When any argument is passed, what is that code?

If I wrote a custom classified code called MyClass how can I control when assures me. Arequal with the type of object type MyClass ?

It is quite toxic and does not explain it, so I believe if the objects are primary If not, their reference will be compared.

That is, the two references of the same object are considered equal; Two clones of the same object will be evaluated as separate unless you surrender to the equality () example method related to those items of class (SAS), or say class (SAP) ) Are related to the == operator.

See also Reid Copsi's answers.

No comments:

Post a Comment