my main target was to compare data stored in DB and in XLSX file.
To do that, I have two lists created following way:
private class ProductList
{
    public string productSku { get; set; }
    public string productName { get; set; }
    public string productSubfamilyId { get; set; }
    public string productSubfamilyName { get; set; }
    public string productFamilyId { get; set; }
    public string productFamilyName { get; set; }
};
(...)
List<ProductList> productListsDB = new List<ProductList>();
List<ProductList> productListsXLSX = new List<ProductList>();
(...)
To first one, I provide data directly from SQL query result:
while (reader.Read())
{
    ProductList pl = new ProductList();
    pl.productSku = reader.GetString(reader.GetOrdinal("ProductSku"));
    pl.productName = reader.GetString(reader.GetOrdinal("ProductName"));
    pl.productSubfamilyId = reader.GetString(reader.GetOrdinal("ProductSubfamilyId"));
    pl.productSubfamilyName = reader.GetString(reader.GetOrdinal("ProductSubfamilyName"));
    pl.productFamilyId = reader.GetString(reader.GetOrdinal("ProductFamilyId"));
    pl.productFamilyName = reader.GetString(reader.GetOrdinal("ProductFamilyName"));
    productListsDB.Add(pl);
}
Another one is filled with data stored in XLSX file:
for (int rowNum = startingRow; rowNum <= totalRows; rowNum++)
{
    var row = myWorksheet.Cells[rowNum, 1, rowNum, totalColumns].ToArray();
    ProductList pl = new ProductList();
    pl.productSku = (string)row[0].Value;
    pl.productName = (string)row[1].Value;
    pl.productSubfamilyId = (string)row[2].Value;
    pl.productSubfamilyName = (string)row[3].Value;
    pl.productFamilyId = (string)row[4].Value;
    pl.productFamilyName = (string)row[5].Value;
    productListsXLSX.Add(pl);
}
Then I wanted to compare them and:
Assert.IsTrue(Equals(productListsDB.Count,productListsXLSX.Count), "Number of records in Excel file and DB differs!");
Passes just fine!
But any of two following does NOT pass:
Assert.IsTrue(productListsDB.All(productListsXLSX.Contains), "Data sent in Excel file and stored in DB are equal.");
CollectionAssert.AreEquivalent(productListsDB, productListsXLSX, "Data sent in Excel file and stored in DB are equal.");
I'm pretty new to writing and debugging code, but I managed to get some insights of that lists with QuickWatch in VS. I copied data to separate files and compered them - they are identical:
http://pastebin.com/KFDHpQkC and http://pastebin.com/4j1n1nPH
Any clues guys?
 
     
     
    