【发布时间】:2016-07-21 04:39:34
【问题描述】:
我收到此错误:
结果堆栈跟踪:在 UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch() 结果消息:测试方法 UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch 抛出 异常:System.MissingMethodException:找不到方法: '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()中。更改return View("QuoteEndCustomerSearch", model);以返回视图(模型); -
感谢 Nkosi 的有用提示
标签: c# debugging testing visual-studio-2015 method-missing