Today, I was working on one of my first ever (actually, it is my 2nd) WCF services. This service was meant to be pretty simple, 1 method with 4 param's. It should not take that long, or will it.
To get the service started, I began by writing the library that the service would actually consume, the business value if you will. Writing this took about 3-4 hours, but in the end it was pretty solid. Along with the library there are 18 tests to prove (hopefully) that I did not miss anything.
So now on to the service. Because I am so new at this, I decided that I would copy the old service and tweak it for the new usage. This took all of 10 minutes, great, I'm pumped. It was time to test it.
In order to test this, I created a new project (wanted to act as if I was an actual consumer) that referenced the service. I whipped up a simple test to test my service. Here we go... It failed (of course, nothing can be that easy). Why did it fail, oh yea. Because none of my interfaces (or concrete objects for that matter) had public setters on properties. In order for serialization to work correctly I had to add these. I really hate that, but what can you do. After a few more tries I was cooking with fire. Or was I?
My service was working, but it was not returning data... Odd. So, I re-ran my original unit test to make sure nothing was broken, and nope, all green. So what could it be. Again, being then newbie at this I did what most newbie's would do, try one thing, nope, then another, nope. After about 2 hours of this I contacted my good buddy Joey for some help. He was very helpful, pointed me in the direction of some nice WCF tools. But sadly, I still had the issue.
Fast forward another 2 hours and I finally found the issue. In my WCF service (btw, the method in the service is a whopping 2 lines of code) I had mistakenly used the same entry param twice in my method call. DOH
It took me 4 hours to determine that my error was caused by 2 things.
- I used the same param in 2 spots in a method
- I did not have a unit test for my service method...(btw, this was the real issue)
So, what is the moral of the story. Unit Tests SAVE TIME.
On a positive note, I did learn a few things along the way, so it was not all a waste.
Till next time :(
Posted
07-17-2007 8:28 PM
by
Derik Whittaker