Unit testing ASP.NET MVC redirection

前端 未结 4 1885
南笙
南笙 2021-02-05 09:50

How do I Unit Test a MVC redirection?

public ActionResult Create(Product product)
{
    _productTask.Save(product);
    return RedirectToAction(\"Success\");   
         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 10:44

    you can use Mvc.Contrib.TestHelper which provides assertions for testing redirections. Take a look at http://kbochevski.blogspot.com/2010/06/unit-testing-mvcnet.html and the code sample. It might be helpful.

提交回复
热议问题