==================
1.Assert.AreSame Method
========================
Verifies that specified object variables refer to the same objects.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aresame(v=VS.100).aspx
2.Assert.AreEqual Method
============================
Verifies that specified values are equal.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.areequal(v=VS.100).aspx
List of test methods:
==============
1. Passed.
1.Assert.AreSame Method
========================
Verifies that specified object variables refer to the same objects.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aresame(v=VS.100).aspx
2.Assert.AreEqual Method
============================
Verifies that specified values are equal.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.areequal(v=VS.100).aspx
List of test methods:
==============
1. Passed.
[TestMethod]
public void IsStringEqualTest
{
const string INPUT = "Obama";
const string EXPEXTED = "Obama"
Assert.AreEqual(EXPEXTED, INPUT);
}
2. Failed
.[TestMethod]
public void IsStringEqualNoIgnoreCaseTest
{
const string INPUT = "Obama";
const string EXPEXTED = "obama"
Assert.AreEqual(EXPEXTED, INPUT);
}
3. Passed.
[TestMethod]
public void IsStringEqualWithIgnoreCaseTest()
{
const string INPUT = "Obama";
const string EXPEXTED = "obama"
Assert.AreEqual(EXPEXTED, INPUT, true);
}
4. Failed
// Please use Assert.AreSame for only ref types.
// For value type useAssert.AreEqual !!!
[TestMethod]
public void IntegerSameTest()
{
int INPUT = 100;
int EXPEXTED = 100;
Assert.AreSame(EXPEXTED, INPUT);
}
5.Passed
.[TestMethod]
public void IntegerSameTest()
{
int INPUT = 100;
int EXPEXTED = 100;
Assert.AreEqual(EXPEXTED, INPUT);
}
Conclution:
===============================
Use Assert.AreSame for only ref types.
For value type use Assert.AreEqual only.===============================
public void IsStringEqualTest
{
const string INPUT = "Obama";
const string EXPEXTED = "Obama"
Assert.AreEqual(EXPEXTED, INPUT);
}
2. Failed
.[TestMethod]
public void IsStringEqualNoIgnoreCaseTest
{
const string INPUT = "Obama";
const string EXPEXTED = "obama"
Assert.AreEqual(EXPEXTED, INPUT);
}
3. Passed.
[TestMethod]
public void IsStringEqualWithIgnoreCaseTest()
{
const string INPUT = "Obama";
const string EXPEXTED = "obama"
Assert.AreEqual(EXPEXTED, INPUT, true);
}
4. Failed
// Please use Assert.AreSame for only ref types.
// For value type useAssert.AreEqual !!!
[TestMethod]
public void IntegerSameTest()
{
int INPUT = 100;
int EXPEXTED = 100;
Assert.AreSame(EXPEXTED, INPUT);
}
5.Passed
.[TestMethod]
public void IntegerSameTest()
{
int INPUT = 100;
int EXPEXTED = 100;
Assert.AreEqual(EXPEXTED, INPUT);
}
Conclution:
===============================
Use Assert.AreSame for only ref types.
For value type use Assert.AreEqual only.===============================
No comments:
Post a Comment