So I generate an empty Dictionary<string,string> to compare to my test result, and then I do this:
Assert.AreEqual(retval, temp);
And it fails even though they contain the same exact data. I’ve also tried using IsTrue like this: Assert.IsTrue(retval.Equals(temp)); and that fails too even if they are the same.
How can I compare just the elements, not the same memory location which I’m assuming it’s doing?
Thanks.
You could do
Assert.IsTrue(retval.SequenceEqual(temp)), although this will also require the order of elements in the dictionaries to be the same. I’m not sure if you want your test for equality to be that strict.See this question and its answers for ways to compare the contents of the dictionaries regardless of sequence.