I want to check for example
int orderId = myRepository.SubmitOrder(orderA);
orderB = myRepository.GetOrder(orderId);
Assert.AreEqual(orderA, orderB);
Obviously, I need a comparison of the values here, but I don't want to provide an overridden implementation of Equals for all my classes solely for testing (this would be useless in the rest of the application).
Is there a generic method provided that just checks each field using reflection? Or, if not, can you write your own?
EDIT . It seems that people do not understand the meaning. I do not want to write my own comparison logic. This will require hundreds of lines of additional code. I'm looking for something like a generic
bool ContainSameValues<T>(T t1, T t2)
which recursively uses reflection to stretch all values to T.
. , - , ()