James Esh
James Esh

Reputation: 2309

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

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

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

Is this possible with NUnit?

Upvotes: 3

Views: 138

Answers (1)

James Esh
James Esh

Reputation: 2309

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")))

Upvotes: 2

Related Questions