It's just a simple cast embedded into the method chain. target.List(int)
returns a ViewResult
. ViewResult.Model
is typed as an Object
so that any model type can be used. Casting it to your ViewModel
type in your test is necessary to tell the compiiler what type Model
is. It's the equivalent of:
ViewModel model = (ViewModel)target.List(1).Model;
int result = model.ModelObject.ObjectProperty;