开发者

Compare 2 lists in MbUnit 3.1

I am trying to compare 2 Dictionary objects for equality in MbUnit 3.1 like so

Assert.AreEqual<FieldList>(expectedOutputFieldList, actualOutputFieldList);

Where FieldList is = Dictionary<开发者_运维问答string, object>

However this throws up the following "error":

Both values look the same when formatted but they are distinct instances.

Is there any method for comparing object data rather than instances?

Thanks in advance...


Try

Assert.AreElementsEqualIgnoringOrder(expectedOutputFieldList, actualOutputFieldList);


Mauricio is absolutely right. But more generally speaking, there are many useful assertions to be used with collections and enumerations in MbUnit v3. You may want to have a look at them:

  • Assert.AreElementsEqual
  • Assert.AreElementsEqualIgnoringOrder
  • Assert.AreElementsNotEqual
  • Assert.AreElementsSame
  • Assert.AreElementsSameIgnoringOrder
  • Assert.AreElementsNotSame
  • Assert.Exists
  • Assert.ForAll
  • Assert.ContainsKey
  • Assert.DoesNotContainKey
  • Assert.Contains
  • Assert.DoesNotContain
  • Assert.IsEmpty
  • Assert.IsNotEmpty
  • Assert.Distinct
  • Assert.Sorted
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜