IEnumerables的'Assert.AreEqual`和`CollectionAssert.AreEqual`之间的Nunit差异

时间:2012-08-08 10:17:14

标签: unit-testing nunit ienumerable

在Nunit,

之间有什么区别吗?
Assert.AreEqual(IEnumerable<T>, IEnumerable<T>)

CollectionAssert.AreEqual(IEnumerable<T>, IEnumerable<T>)

1 个答案:

答案 0 :(得分:2)

没有重载Assert.AreEqual(IEnumerable<T>, IEnumerable<T>),只有Assert.AreEqual(object, object)。至少对于nunit 2.5.10,它们的实现是相同的:

CollectionAssert.cs

public class CollectionAssert
{
    public static void AreEqual(IEnumerable expected, IEnumerable actual)
    {
      Assert.That((object) actual, (IResolveConstraint) new EqualConstraint((object) expected));
    }
}

Assert.cs

public class Assert
{
    public static void AreEqual(object expected, object actual)
    {
      // EqualConstraint EqualTo(object expected)
      Assert.That(actual, (IResolveConstraint) Is.EqualTo(expected), (string) null, (object[]) null);
    }
}