Closed Edimarcos-Maranhao closed 6 years ago
Hi @Edimarcos. Thanks for you question. Behavior you described is correct. If the numbers of elements are not the same Comparer doesn't compare elements. This situations can be tricky because:
In your case the best way would be to implement custom Comparer (it should implement IComparer<IList
As an enhancement for the future I'll be thinking about adding some generic Comparers for lists to make handling cases like this easier.
@Edimarcos I added your example (a bit simplified) to the list of examples (Example 4). You need version 1.2.1 to make it work because of a small issue in the default Factory implementation. Enjoy!!!! :)
1 - I can not get differences from class members by comparing two lists where the quantity of items are different, when the lists are equal I get the differences. 2 - Dates equal get differences.
Example of model:
Example of Implementation of the tests:
DifferenceType=ValueMismatch, MemberPath='Name', Value1='Aenean Lorem Nibh', Value2='Aenean Quisque Nibh' DifferenceType=ValueMismatch, MemberPath='Initials', Value1='ALN', Value2='AQN'
DifferenceType=ValueMismatch, MemberPath='CreationDate', Value1='06/10/2018 18:04:57', Value2='06/10/2018 18:04:57'
DifferenceType=ValueMismatch, MemberPath='Items[0].Delay', Value1='60', Value2='30' DifferenceType=ValueMismatch, MemberPath='Items[0].Name', Value1='Duis et rhoncus risus', Value2='Nulla ac vulputate magna' DifferenceType=ValueMismatch, MemberPath='Items[0].Instruction', Value1='Lorem ipsum dolor sit amet, consectetur adipiscing elit', Value2='Phasellus nisl tortor, malesuada eget elit id, finibus volutpat est'
DifferenceType=ValueMismatch, MemberPath='Name', Value1='Aenean Lorem Nibh', Value2='Aenean Quisque Nibh' DifferenceType=ValueMismatch, MemberPath='Initials', Value1='ALN', Value2='AQN' DifferenceType=ValueMismatch, MemberPath='CreationDate', Value1='06/10/2018 18:01:27', Value2='06/10/2018 18:01:27'
DifferenceType=ValueMismatch, MemberPath='Items.Count', Value1='1', Value2='2'
Is there something I'm not implementing or would it be a bug? I use the net461 framework in my tests.