Unit testing ASP.NET MVC redirection -


how unit test mvc redirection?

public actionresult create(product product) {     _producttask.save(product);     return redirecttoaction("success");    }  public actionresult success() {       return view(); } 

is ayende's approach still best way go, preview 5:

 public static void renderview(this controller self, string action)   {     typeof(controller).getmethod("renderview").invoke(self,new object[] { action} );   } 

seems odd have this, mvc team have said writing framework testable.

[testfixture] public class redirecttester {     [test]     public void should_redirect_to_success_action()     {         var controller = new redirectcontroller();         var result = controller.index() redirecttorouteresult;         assert.that(result, is.not.null);         assert.that(result.values["action"], is.equalto("success"));     } }  public class redirectcontroller : controller {     public actionresult index()     {         return redirecttoaction("success");     } } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -