BizTalk Utilities CV ,   Jobs ,   Code library
 
Go to the front page to continue learning about XML or select below:

Contents

ReBlogger Contents

Previous posts in WSCF/WCF

 
 
Page 3986 of 20224

A practical example on how to mock static classes without TypeMock

Blogger : Daniel Cazzulino
All posts : All posts by Daniel Cazzulino
Category : WSCF/WCF
Blogged date : 2008 May 19

WCF is the second biggest framework after ASP.NET that sooner or later forces you to use a static "context" property to do anything beyond the trivial stuff. ASP.NET has the HttpContext.Current, whereas WCF has the WebOperationContext.Current for example.

My friend Pablo Cibraro proves how you can quite easily make your implementations that depend on such static contexts testable without resorting to black-magic voodoo TypeMock kind of stuff. Any .NET developer can trivially introduce an indirection to make their classes testable, even if they depend on static classes.

So, don't buy a product just because you're lazy and want to avoid creating a few wrapper classes and interfaces. Most of them can be copied directly from Reflector's API rendering. And once you have the interfaces, you can just use MoQ to mock them any way you want.

Always use the simplest thing that could possibly work.


Read comments or post a reply to : A practical example on how to mock static classes without TypeMock
Page 3986 of 20224

Newest posts
 

    Email TopXML