i have a .NET class in which i implemented GetHashCode and Equals.
while i believe i covered all properties and have tests for these functions, there could be a case in the future that someone adds a property and forgets to add it to the GetHashCode and Equals functions. forgetting these function will result in the Equals function returning true for objects that differ by the new property.
I am looking for some tool or code that i can use in the testing code, that will loop through all existing properties of an object and test if something was forgotten.
the unit test will look something like this:
for each property in TargetType
dim instance1 as new TargetType
dim instance2 as new TargetType
instance1.property=1
instance2.property=2
Assert.AreNotEqual(instance1,instance2)
next
of course the property assignment should be smart to use the correct data type