NUnit Collection Assert That item in list is after/before another item

Viewed 63

I would like to do something along the lines of...

Assert.That(collection, Has.Item("two").After.Item("one"))

Is this possible with NUnit?

1 Answers

From the looks of this page, I'm out of luck this time (thanks @canton7). A suggestion was made to make a custom constraint, which I find fascinating, but probably an overkill for this scenario.

Here's how I ended up doing it:

Assert.That(collection.IndexOf("two"), Is.GreaterThan(collection.IndexOf("one")))
Related