3

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.

Sniipe
  • 115
  • 1
  • 8
  • 1
    if the view has the same name as the action then there is no need to inclide it in `View()`. Change `return View("QuoteEndCustomerSearch", model);` to return View(model); – Nkosi Apr 01 '16 at 11:46
  • Thanks for the helpful tip Nkosi – Sniipe Apr 01 '16 at 20:02

1 Answers1

3

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.

Sniipe
  • 115
  • 1
  • 8