Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Nth item from SelectList

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.

like image 849
fearofawhackplanet Avatar asked Dec 28 '22 15:12

fearofawhackplanet


1 Answers

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

like image 86
Laurent Avatar answered Jan 12 '23 02:01

Laurent