我们如何将单元测试模型传递给视图? [英] How can we unit test model passed to view?

查看:98
本文介绍了我们如何将单元测试模型传递给视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例代码

Sample Code

public ActionResult SubjectExpertsList()
        {
            UsersListViewModel model = new UsersListViewModel();
            model.UsersList = _userService.UsersList(Convert.ToInt32(Session["organizationId"]));
            model.UsersList = model.UsersList.Where(u => u.RoleId == 5).ToList();
            return View(model);
        }



我想用我期望的值测试模型值。怎么样?


I want to test ths model values with my expected value. How?

推荐答案

请阅读下面的文章。可能是你的起点。好运:)



在Visual Studio中使用NUnit进行ASP.NET MVC单元测试
Please read below article.May be the starting point for you.Good Luck :)

ASP.NET MVC Unit Testing using NUnit in Visual Studio


不建议对视图进行单元测试
unit testing of the view is not recommended


这篇关于我们如何将单元测试模型传递给视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆