Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Without more information or code, it's difficult to provide a specific answer. However, here are a few potential reasons why Is.EquivalentTo method might not work as intended for a List<t> in C# NUnit:

  1. It could be due to the fact that List<t> does not implement the IEquatable<t> interface. This means that the default implementation of Equals() checks references rather than comparing the actual contents of the list. To compare list contents, you might need to create a custom implementation of Equals() or use a different method such as SequenceEqual().

  2. Another reason could be that the Is.EquivalentTo method might not be comparing the lists in the way you expect. For example, it might only consider the order of the elements, or it might not consider elements that are null or have different data types.

  3. The Is.EquivalentTo method might also have issues with comparing complex objects or objects with nested properties, as it may not handle these comparisons correctly unless custom equality comparers are implemented.

To troubleshoot this issue, you could try using a different comparison method, such as SequenceEqual(), or implement custom equality comparers. You could also check the documentation for NUnit and the List<t> class to ensure that you are using the methods and properties correctly.