[英]VS2015 Unit test project is unable to find a method
I'm getting this error: 我收到这个错误:
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)'.
结果StackTrace:at UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch()结果消息:测试方法UnitTestProject.ControllerTest.TestMethodQuoteEndCustomerSearch引发异常:System.MissingMethodException:找不到方法:'System.Web.Mvc.ActionResult QuoteCenter.Controllers.ECSearchController.QuoteEndCustomerSearch(System。 String,System.String,System.String,System.String)'。
My Test class looks like this: 我的Test类看起来像这样:
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;
}
}
}
The intellisense knows that myController has a method QuoteEndCustomerSearch. intellisense知道myController有一个方法QuoteEndCustomerSearch。 But when I debug I get the above error.
但是当我调试时,我得到了上述错误。
The controller's method looks like this: 控制器的方法如下所示:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult QuoteEndCustomerSearch(String quoteId, String CID, String URL, String UserID)
{
//...
return View("QuoteEndCustomerSearch", model);
}
Any tips on what else I should try to get it working? 关于我应该尝试使其工作的其他任何提示? I'm in Admin mode and I've restarted VS2015.
我处于管理员模式,我重新启动了VS2015。
The issue was that my existing project had mvc version 5 but the new test project had a newer version. 问题是我现有的项目有mvc版本5,但新的测试项目有一个更新的版本。 All good now.
一切都好。 I didn't notice when I was using Nuget that the versions were different.
当我使用Nuget时,我没注意到版本不同。 I think now is a good time for me to update all projects to the newest version of MVC.
我认为现在是我将所有项目更新到最新版MVC的好时机。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.