Make WCF client/proxy IOCable

For unit-test purpose, it’s necessary to make WCF client/proxy class implement from an interface.

The problem is, we suppose to clean up this WCF client after each service call, which means it should be able to repeatedly contracted and disposed. From IOC container we can only get it once. A factory for WCF client is the only solution.

There is an OSS lib from SoftwareIsHardwork. Very detail document.

I personally like Michael Perry’s POCO better:  Client object is created and closed in each service method call, and method is wrapped in lambda expression, very clean and smart.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s