本文介绍了如何模拟继承的基类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的控制器类继承自basecontroller而不是控制器,如下所示:

Say my controller class is inheriting from a basecontroller instead of controller like shown below:

public partial class ProductController : BaseController
   {
         public ActionResult Index()
         {
          //Code to the controller action
          }
   }



我的BaseController有这样的定义


And my BaseController has a definition like this

 public abstract partial class BaseController : Controller
{
    public BaseController()
    {
     //Code to Base Controller Constructor
    }

}



因此,在对控制器进行单元测试时,是吗可以模拟BaseController,即基类.. ?? ..

请帮助...


So, while unit testing for the controller, is it possible to mock the BaseController, i.e. base class..??..
Please help...

推荐答案


这篇关于如何模拟继承的基类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 13:00