Question

I'm trying to unit test a function which returns a SelectList.

How can I retrieve an item from the SelectList to verify that my model is being constructed correctly?

mySelectList.Items.First().DataValue

or whatever.

Was it helpful?

Solution

Simply use mySelectList.ElementAt(n) to get the nth SelectListItem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top