2016-04-01 47 views
3

我得到这个错误: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。

+1

如果视图与动作名称相同,则不需要将其放在'View()'中。更改'返回视图(“QuoteEndCustomerSearch”,模型);'返回视图(模型); – Nkosi

+0

感谢您提供有用的提示Nkosi – Sniipe

回答

2

问题是我现有的项目有mvc版本5,但新的测试项目有一个更新的版本。现在都好。 我没有注意到当我使用Nuget的版本不同时。 我认为现在是我将所有项目更新到最新版MVC的好时机。