我正在努力做出关于枚举中缺少特定项目的断言.具体来说,这就是我的测试结果:
// Take an item from a queue of scheduled items...
ItemQueue pendingQueue = schedule.PendingItems; // PendingItems is an IEnumerable<int>
int item = pendingQueue.FirstItem;
// ...process the item...
processor.DoSomethingWith(item);
// ...and the schedule must not contain the item anymore:
Assert.That(schedule.PendingItems, Does.Not.Contain(item));
Run Code Online (Sandbox Code Playgroud)
当然,Does.Not.Contain不是有效的nUnit约束.如何用有效的流利语法表达它?
gco*_*res 48
Assert.That(schedule.PendingItems, Has.No.Member(item))
Run Code Online (Sandbox Code Playgroud)
仅适用于NUnit 2.4/2.5
Rok*_*iša 13
使用CollectionAssert方法:
CollectionAssert.DoesNotContain(schedule.PendingItems, item);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6615 次 |
| 最近记录: |