Testing the ASP.NET MVC RedirectResult Module

I have a class that inherits from System.Web.Mvc.RedirectResult that overrides ExecuteResult . How to do unit test?

Thanks.

+4
source share
1 answer

Depends on what you redefine.

In general, mock HttpContextBase , create the necessary RouteData and use these two elements to create the ControllerContext .

Create your own RedirectResult , call ExecuteResult , passing in the previously created ControllerContext , and then create statements for the various fragments that you are mocking.

If you want a more complete answer, I will need more detailed information about what exactly your redefinition does.

+1
source

All Articles