开发者

Compare 2 lists in MbUnit 3.1

开发者 https://www.devze.com 2022-12-29 18:13 出处:网络
I am trying to compare 2 Dictionary objects for equality in MbUnit 3.1 like so Assert.AreEqual<FieldList>(expectedOutputFieldList, actualOutputFieldList);

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

精彩评论

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