【发布时间】:2014-07-30 22:16:23
【问题描述】:
我的控制器文件中有以下内容:
public ActionResult Index()
{
var model = new ClientGroupIndexViewModel()
{
AddScanUrl = Url.RouteUrl<ClientGroupsController>(c => c.CreateNewScan(null, null)),
//other similar stuff
};
return View("ClientGroupsIndex", model);
}
public JsonResult CreateNewScan(ClientGroup clientGroup, Version version)
{
//do something
return Json(new{Message = "created new scan", Success = true});
}
我要为 CreateNewScan 编写单元测试用例。如何做到这一点(最好使用 VS 中的内置测试框架)?任何这方面的指针表示赞赏。
【问题讨论】:
-
使用@Zafar 发布的链接,您可能需要检查测试中的 Success 值。
-
@Darek 试图在发布的链接中寻求答案,但我完全是新手,不太了解。非常感谢任何进一步的帮助。
标签: c# asp.net .net asp.net-mvc unit-testing