Here's my test function (c#, visual studio 2010):
[TestMethod()]
public void TestGetRelevantWeeks()
{
List<sbyte> expected = new List<sbyte>() { 2, 1, 52, 51, 50, 49, 48, 47, 46, 45 };
List<sbyte> actual = new List<sbyte>() { 2, 1, 52, 51, 50, 49, 48, 47, 46, 45 };
Assert.AreEqual<List<sbyte>>(expected, actual);
}
Exception:
Failed TestGetRelevantWeek Assert.AreEqual failed.
Expected:System.Collections.Generic.List 1[System.SByte].
Actual:System.Collections.Generic.List 1[System.SByte].
Does AreEqual only check equality of the reference, not the contents?
But then, the exception message would be confusing. I also couldn't find a documentation of the default equality comparer for a generic list.
Could you help to clarify why the test fails and what would be solutions for testing the equality of the contents of both lists?
Kind regards
The Three Common Causes of Exam Failure. There are three main ways that students of all ages can sabotage themselves in exams and bed up with an exam results fail: poor exam technique, poor revision and weak understanding of the subject itself. These can all lead to a bad day in the school exam hall.
Test Failure means a break or rupture that occurs during strength proof testing of transmission or gathering lines that are of such magnitude as to require repair before continuation of the test.
Test cases usually fail due to server and network issues, an unresponsive application or validation failure, or even due to scripting issues. When failures occur, it is necessary to handle these test cases and rerun them to get the desired output. An efficient way to do this is to use the TestNG suite.
Remind yourself that these feelings are temporary by engaging in activities that bring you joy — doing so reinforces that life goes on and everything will be okay. As little as a few minutes doodling, gardening, reading, dancing, or singing along to your favorite song may ameliorate your mood.
The Assert.AreEqual()
method does a reference equality test as you expected.
Assuming you're using .Net 3.5 or above, you can do this:
using System.Linq;
Assert.IsTrue(expected.SequenceEqual(actual));
Edit: Clarified when this option is available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With