Thunderdome action invoker asp.net mvc

I know the basic idea of ​​the thunder principle (one object enters, one object leaves), but I have not seen any real example of this in asp.net mvc. Is this a good example of a lightning rod principle

  public ActionResult Index(Employee employee)
        {
             //some actions here
             return View(employeeViewModel);
        }

But what about the statement

Controller classes will never be directly exposed to anything related to the HttpContext

What does an action invoker look like? Could you give some examples and unit tests for this?


from http://codebetter.com/blogs/jeremy.miller/archive/2008/10/23/our-opinions-on-the-asp-net-mvc-introducing-the-thunderdome-principle.aspx

"Thunderdome principle" - all controller methods take one ViewModel object (or in some cases zero objects) and return one ViewModel object (one object enters, one object leaves). Controller classes will NEVER be directly affected by the HttpContext-related action. Nothing makes me cry like seeing people trying to write tests that make fun or close this new IHttpContextWrapper interface. Similarly, controller methods do not return ViewResult objects and are typically disconnected from the entire MVC infrastructure. We adopted this strategy very early in order to simplify the mechanical testing of the controller.

But I want to know how to do this? how to write such an action invoker controller? because we usually have to mock httpcontext

+3
2

, OMIOMO (Thunderdome) Action ASP.NET MVC Oxite rev2.

, OxiteActionInvoker: http://oxite.codeplex.com/SourceControl/changeset/view/31497#442766

, OMIOMO: http://oxite.codeplex.com/SourceControl/changeset/view/31497#442745

, Oxite , IoC- ( - OCP, ). OxiteActionInvoker "GetFilters", FilterRegistry .

+1

" ( , )" MVC. trhings ViewData ViewTemp .

jscportal

, jscportal\JSC.Portal.Web\Controllers\TemplatesController.cs , :

public ActionResult List()
{
    IList<Template> templates = Service.GetAll();
    return View(templates);
}

public ActionResult Edit(int id)
{
    Template t = Service.GetById(id, false);
    return View(t);
}

!

0

Source: https://habr.com/ru/post/1708148/


All Articles