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.
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.
Simply use mySelectList.ElementAt(n)
to get the nth SelectListItem.
© 2022 - 2024 — McMap. All rights reserved.