FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
SOA Web Services Blog: Testing services the hard way with WCF
XML & Web Services
<![CDATA[[

Web Services and Smart Data.

by John Dorsey
THE SOFTWARE SIMPLIST

Web Services Wisdom.

by Udi Dahan
June 22, 2007

Testing services the hard way with WCF

I just read the kind of hoops you have to go through in order to test your WCF service implementations. Oh. My. GOD.

If that's the best there is, NOBODY is going to be testing their WCF services. That's scary.

When using this message-based design, your service implementations tend to look like this:

public class WorkflowMessageHandler : IMessageHandler
{
	public void Handle(Stage1Msg msg)
	{
		using (IDBScope scope = this.DbServices.GetScope(TransactionOption.On))
		{
			IWorkflow wf = this.DbServices.Get(msg.WorkFlowID);
			wf.Handle(msg);

scope.Complete();
}
}
}

And it's this easy to test them:

[TestMethod]
public void TestWorkflowMessageHandler()
{
	WorkflowMessageHandler handler = new WorkflowMessageHandler();
	handler.Bus = this.MockBus;

// set up expectations on bus in terms of messages returned

Stage1Msg msg = new Stage1Msg();
// fill msg with data

handler.Handle(msg);

// verify expectations on bus
}

That's right, it's just plain old unit testing the way we test everything else these days.

I'm beginning to get the impression that the new suite of technologies that is coming out of Microsoft is making things more complicated than they need to be.

Well, maybe that's just me.

Posted by Udi Dahan at 08:50 AM  Permalink




 
INFO-LINK