Подтвердить что ты не робот

Создание ограничения NUnit, означающего "{collection}, не содержит {item}"

Я изо всех сил пытаюсь сделать утверждение об отсутствии определенного элемента в перечислении. В частности, это мой тест выглядит следующим образом:

// 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. Как я могу выразить это в действительном свободном синтаксисе?

4b9b3361

Ответ 1

Assert.That(schedule.PendingItems, Has.No.Member(item))

Только с NUnit 2.4/2.5

Ответ 2

Используйте метод CollectionAssert:

CollectionAssert.DoesNotContain(schedule.PendingItems, item);