I'm struggling to make an assertion about the absence of a particular item in an enumeration. Specifically, this is what my test looks like:
// 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));
Of course, Does.Not.Contain is not a valid nUnit constraint. How can I express it in a valid fluent syntax?
Assert.That(schedule.PendingItems, Has.No.Member(item))
Only with NUnit 2.4 / 2.5
Use the CollectionAssert method:
CollectionAssert.DoesNotContain(schedule.PendingItems, item);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With