Assert.AreEqual() Exception in VS2010

Posted by Tom Miller on Stack Overflow See other posts from Stack Overflow or by Tom Miller
Published on 2010-05-24T15:17:05Z Indexed on 2010/05/24 15:21 UTC
Read the original article Hit count: 1085

I am fairly new to unit testing and am using VS2010 to develop in and run my tests. I have a simple test, illustrated below, that simply compares 2 System.Data.DataTableReader objects. I know that they are equal as they are both created using the same object types, the same input file and I have verified that the objects "look" the same.

I realize I may be dealing with a couple of issues, one being whether or not this is the proper use of Assert.AreEqual or even the proper way to test this scenario, and the other being the main issue I am dealing with which is why this test fails with this exception:

Failed 00:00:00.1000660 0 Assert.AreEqual failed. 
Expected:<System.Data.DataTableReader>. Actual:<System.Data.DataTableReader>. 

Here is the unit test code that is failing:

public void EntriesTest()
{
    AuditLog target = new AuditLog(); 

    target.Init();

    DataSet ds = new DataSet();
    ds.ReadXml(TestContext.DataRow["AuditLogPath"].ToString());
    DataTableReader  expected = ds.Tables[0].CreateDataReader();
    DataTableReader actual = target.Entries.Tables[0].CreateDataReader();
    Assert.AreEqual<DataTableReader>(expected, actual);
}

Any help would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about .NET

Related posts about unit-testing