What is the difference between:
Assert.Equals
and Assert.AreEqual
Assert.NotNull
and Assert.IsNotNull
?
It means that AreSame() checks that they are the exact same object - if reference indicate the same object in memory. AreEqual() checks that objects has equal type and value. Equal objects can exist in two different places in memory.
Tests whether the specified objects are equal and throws an exception if the two objects are not equal. Different numeric types are treated as unequal even if the logical values are equal.
Assert. AreEqual() compares references. Usually when comparing lists I compare the count of the items and than some properties of one exact item in the list or directly the item in the list (but again it is the reference).
Assert. Equal(expected.Name, actual.Name); The first example fails due to the way comparison works for reference types. By default, the equality operation for those types will only assert whether the two objects being compared are the same, namely your variables are pointing to the same object within the memory heap.
Assert.Equals is an object comparison
Assert.AreEquals is overloaded to compare (int,double, object) etc
Assert.NotNull and Assert.IsNotNul appear to be identical.
http://www.nunit.org/index.php?p=conditionAsserts&r=2.5.5
Just read the documentation:
NUnit - ConditionAsserts
Two forms are provided for the True, False, Null and NotNull conditions. The "Is" forms are compatible with earlier versions of the NUnit framework, while those without "Is" are provided for compatibility with NUnitLite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With