Reputation: 18237
If I had a custom class that inherits from Collection called LookUpValueCollection
that handle only types of the class LookUpValueCollection
, to use the method CollectionAssert
with Visual Studio test Do I need to implement the method IEqual to handle the comparison? Because I used and despite of two collection are similar still says that the objets inside are different.
Upvotes: 1
Views: 170
Reputation: 292425
Yes, the elements of the collection need to override Equals
(and GetHashCode
). Otherwise, the elements will be compared by reference, so they won't be considered equal if they're not the same instance.
Upvotes: 2