Welcome to Manicprogrammer Sign in | Join | Help

Asp.Net Action Filters - Can't test them? Stormwind comes to your help!

Once more my friend Claudio Figueiredo amazed me coming up with a brilliant solution to a problem that was starting to shadow an otherwise brilliant implementation of the MVC Pattern.

The new ASP.Net MVC Framework allows you to specify Action Filters. You can learn more about them in his post here (and check his solution to this problem as well).

These Action Filters are brilliant, in which they allow us amazing possibilities like logging actions when needed, caching Action Results, or anything that you can think in the ways of intercepting action calls.

The problem is (well, was) that they're not testable per se. The issue here being that currently the MVC Framework will not call them when you just create your own Controller in your test and call the action directly (which kinda makes sense).

So Claudio came up with a clever way of mimicking ASP.Net MVC's calls of the ActionFilters. If you call the action using his extension method, you'll get all the goodies that you would normally get from the framework.

Enough of reading my post! Go read his now!

Published Sunday, July 13, 2008 7:28 PM by heynemann
Filed under , , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# ASP.NET MVC Archived Blog Posts, Page 1

Sunday, July 13, 2008 10:02 PM by ASP.NET MVC Archived Blog Posts, Page 1

Enter the text you see in the image:

Leave a Comment

(required) 
required 
(required)