Ответ 1
Assert.That(schedule.PendingItems, Has.No.Member(item))
Только с NUnit 2.4/2.5
Я изо всех сил пытаюсь сделать утверждение об отсутствии определенного элемента в перечислении. В частности, это мой тест выглядит следующим образом:
// 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));
Конечно, Does.Not.Contain не является допустимым ограничением nUnit. Как я могу выразить это в действительном свободном синтаксисе?
Assert.That(schedule.PendingItems, Has.No.Member(item))
Только с NUnit 2.4/2.5
Используйте метод CollectionAssert:
CollectionAssert.DoesNotContain(schedule.PendingItems, item);
Если вы используете NUnit 2.4/2.5, вы можете проверить ограничения коллекции.