我在.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