我在.NET 3.5 C#应用程序中使用NUnit 2.5.6.10205。我使用NUnit的Collection Constraint来断言IEnumerable是否由参数排序。NUnit CollectionConstraints例外
它似乎并没有为我工作,因为我收到一个异常,指出我的实际值不是IEnumreable。 allEntities是一个List<T>
,它实现了IEnumerable<T>
。我相信NUnit正在寻找IEnumerable
,而不是IEnumerable<T>
,但IEnumerable<T>
执行IEnumerable
。这是一个共同/反对差异的问题吗?
Assert.That(allEntities, Is.All.Ordered.By("CreationDate"));
。
System.ArgumentException : The actual value must be an IEnumerable
Parameter name: actual
另外,有没有什么方法可以表达使用Lambda的排序属性?对属性使用文字字符串会使其变脆。
我会给你支票所以它看起来并不像我提出了一个问题,只是回答我自己:) –
THX,但你在15秒内速度更快:)。 +1给你更完整的答案。 – nemesv