Click here to Skip to main content
15,886,110 members
Articles / Web Development / ASP.NET

Testing MVC with Ivonna -- first look

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
23 Jul 2011CPOL1 min read 7.1K   1   1
Testing MVC with Ivonna -- first look

Recently I've been adding some bits to Ivonna that are supposed to make her more MVC-friendly. I fell asleep with a happy smile on my face after the following test passed:

C#
var session = new TestSession();
var response = session.Get("/");
Assert.AreEqual("Home", response.ControllerName);

As before, we have a WebResponse class, but this one stays in the Ivonna.Framework.MVC namespace. The one that was used all along has been moved to the Ivonna.Framework.Webforms namespace, so all you need to make your old code compile is add an import. TestSession.Get() is an extension method: it has WebForms and MVC "flavours", depending on which namespace you import. This way, you don't have to learn a new syntax for a different framework. Of course, you can still use TestSession.ProcessRequest() if you need to customize your request.

What's implemented already is full information about the action method: the ControllerContext and ActionDescriptor instances, and parameter values participating in the method invocation. You can get the Route through these as well, but I plan to expose it as a property. The next step is provide the information about the ActionResult, including the IView instance, if any. So, the WebResponse instance will contain the full information about the request. Information about the child requests will be available as well.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer GeekSoft
Lithuania Lithuania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionNice to be here.... Pin
sanamirza24-Jul-11 23:57
sanamirza24-Jul-11 23:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.