Unit Testing, WCF and MEF
Intro
This article will focus on how I’ve adopted unit testing in .NET using MEF and how to also apply this to WCF web services.
I haven’t been dedicated to unit testing for a long time but once I started I couldn’t stop. There are many great benefits to doing unit tests, I wont list them here but a good article to read is at: Agitar.com
What made me build something on my own? I wanted something light that I could also integrate into existing code without making too many changes. So I focused on a couple of things: Testing and Dependency Injection. I wanted an elegant solution that didn’t rely on external libraries or that will require a steep learning-curve.
In this article I will focus on these topics and how I solved it for myself. I’m not going to dive into other topics such as The SOLID principals, TDD, Dependency Injection, Mocking, etc. If these terms are not familiar to you, I suggest you read up on them first.
I’m actually going to divide this article into two parts, to keep them shorter and to the point:
- This first part will discuss how to do testing with MEF.
- The second will discuss how to use MEF and test for a WCF service.