What’s Wrong With This Code (#25)
Posted
on Dot net Slackers
See other posts from Dot net Slackers
Published on Mon, 03 May 2010 00:00:00 GMT
Indexed on
2010/05/03
14:58 UTC
Read the original article
Hit count: 217
Filed under:
The goal: create an extension method that will make it easy to create FormCollection objects. The method is a helper for unit testing ASP.NET MVC code. public static FormCollection ToFormCollection(this object data)
{
var namesAndValues =
data.GetType()
.GetProperties()
.WhereValueIsNotDefaultValue(data)
.ToNameValueCollection(data);
return new FormCollection(namesAndValues);
}
The extension method itself relies on a couple private extension...
Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.
© Dot net Slackers or respective owner