Like any other answer, the problem is that you are trying to compare Supplier instances [probably] without overriding the Equals method. But I donβt think you should redefine Equals for testing purposes , as this may affect the production code, or you may need different Equals logic in the production code.
Instead, you must either state each member one by one, as you do in the first example (unless you have a large number of places where you want to compare the entire object), or encapsulate this comparison logic in a certain class and use this class:
static class SupplierAllFieldsComparer { public static void AssertAreEqual(Supplier expected, Supplier actual) { Assert.AreEqual(expected.SupplierID , actual.SupplierID ); Assert.AreEqual(expected.SupplierName , actual.SupplierName ); } }
// Test code:
SupplierAllFieldsComparer.AssertAreEqual(expected, actual);
source share