简体   繁体   中英

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)'.

My Test class looks like this:

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. 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.

The issue was that my existing project had mvc version 5 but the new test project had a newer version. All good now. I didn't notice when I was using Nuget that the versions were different. I think now is a good time for me to update all projects to the newest version of MVC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM