You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should().BeEquivalentTo() throws "Sequence contains more than one matching element" when comparing classes that have a field that uses the "new" keyword to hide a field with the same name. #1982
I have class A that inherits class ABase. ABase contains field Id of type string. A has its own Id string field declared as new to hide the Id member coming from ABase.
Scenario:
Calling A.Should().BeEquivalentTo(A)
Expected:
The two fields are compared correctly for equivalency and the proper result is returned.
Actual:
Throws "Sequence contains more than one matching element", thrown on line 144 (return list. SingleOrDefault()) in method TypeExtensions.FindProperty() in my decompiled code.
Note:
Does not happen if you compare the same class instance to itself.
I have class
Athat inherits classABase.ABasecontains fieldIdof typestring.Ahas its ownIdstring field declared asnewto hide theIdmember coming fromABase.Scenario:
Calling
A.Should().BeEquivalentTo(A)Expected:
The two fields are compared correctly for equivalency and the proper result is returned.
Actual:
Throws "Sequence contains more than one matching element", thrown on line 144 (return list. SingleOrDefault()) in method
TypeExtensions.FindProperty()in my decompiled code.Note:
Does not happen if you compare the same class instance to itself.