Assert.AreEqual () exception in VS2010

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

I understand that I can deal with several problems: one of them is the correct use of Assert.AreEqual or even the correct way to test this script, and the other is the main problem that I am dealing with, so this test does not run with this exception:

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

Below is the unit test code:

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!

+3
5

, DataTableReader Equals; Equals ; , .

, , - . CollectionAssert.AreEquivalent(). , CollectionAssert.AreEqual().

+6

, , - , 2 DataReaders , , .

, , DataTables , CollectionAssert.

+2

; . , , .

0

, . , - :

Assert.AreEqual(expected.FieldCount, actual.FieldCount);
for(int i = 0; i < expected.FieldCount; i++)
{
    Assert.AreEqual(expected[i], actual[i]);
}
0

, , , , , , . , ( ), , , .

.

0
source

Source: https://habr.com/ru/post/1746871/


All Articles