我得到这个错误:VS2015单元测试项目是无法找到一个方法
Result StackTrace: at UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch() Result Message: Test method UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch threw exception: System.MissingMethodException: Method not found: 'System.Web.Mvc.ActionResult QuoteCenter.Controllers.ECSearchController.QuoteEndCustomerSearch(System.String, System.String, System.String, System.String)'.
我的测试类是这样的:
namespace UnitTestProject
{
[TestClass]
public class ControllerTest
{
[TestMethod]
public void TestMethodQuoteEndCustomerSearch()
{
//arrange
ECSearchController myController = new ECSearchController();
//ISSUE WITH THE NEXT LINE
ViewResult result = myController .QuoteEndCustomerSearch("", "", "", "") as ViewResult;
}
}
}
智能感知知道有myController的方法QuoteEndCustomerSearch 。但是,当我调试我得到上述错误。
控制器的方法是这样的:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult QuoteEndCustomerSearch(String quoteId, String CID, String URL, String UserID)
{
//...
return View("QuoteEndCustomerSearch", model);
}
,我应该设法把工作还有什么有什么建议?我处于管理员模式,我已重新启动VS2015。
如果视图与动作名称相同,则不需要将其放在'View()'中。更改'返回视图(“QuoteEndCustomerSearch”,模型);'返回视图(模型); – Nkosi
感谢您提供有用的提示Nkosi – Sniipe