ASP.NET MVC unit test controller with HttpContext

前端 未结 5 1325
攒了一身酷
攒了一身酷 2020-11-28 07:21

I am trying to write a unit test for my one controller to verify if a view was returned properly, but this controller has a basecontroller that accesses the HttpContext.Curr

5条回答
  •  鱼传尺愫
    2020-11-28 07:30

    You should probably use an ActionFilter instead of a base class for this sort of thing

    [UserIdBind]
    public class IndexController : Controller
    {
        public ActionResult Index()
        {
            return View("Index.aspx");
        }
    }
    

提交回复
热议问题