문제
I'm returning a list to my MVC controller from Massive. When I'm in my test how can I check that there are 3 records (as expected) in the returned list?
My test code currently returns the 3 records from a call and populates into my ViewModel (model) but when I try to run .Count()
it's saying object has no Count
method. Since it's a dynamic
type what do I do?
My test code:
var result = _controller.Index() as ViewResult;
var model = result.Model as MyExperienceListModel;
Assert.AreEqual(3, model.Experience.Count());
model.Experience is dynamic
btw.
해결책
I got this working by having my returned result set from my Massive class as a IEnumerable<dynamic>
in my ViewModel
. So:
MyExperienceListModel{
public IEnumerable<dynamic> Experience { get; set;}
}
Hope it helps someone else out.
제휴하지 않습니다 StackOverflow