O'Reilly logo

Professional Test-Driven Development with C#: Developing Real World Applications with TDD by Jeff McWherter, James Bender

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SUMMARY

WCF services are becoming more widespread in .NET applications. As the users' needs change and new form factors such as mobile devices become popular, the need for services will only increase. It's important to have a testing strategy for WCF services in your application development practice.

Well-designed WCF services contain no business logic. Instead, they rely on the business logic in the application domain layer, which the WCF service consumes. The WCF service itself should concern itself only with processing specific to itself, such as validation and type translation. This results in WCF services that are short and simple. But these services are still code and still need to be tested.

With dependency injection frameworks such as Ninject, you can eliminate statically bound dependencies from your WCF services. The ability to inject dependencies opens the door to WCF services that are testable. Once the WCF service application can support dependency injection, it becomes a simple matter to test your WCF services as you would any other class: Supply the test implementation with mocked dependencies, and verify their functionality.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required