2

在Nunit中,有什么区别

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

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

?

4

1 回答 1

2

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

集合断言.cs

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

断言.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);
    }
}
于 2012-08-08T10:45:35.507 回答