开发者

Testing results with Massive

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜