-=//mawi.org//=-
 Monday, May 21, 2007

This week was short work-wise, and went by quickly. Last week was hectic and long. Me and my colleague Truls gave a seminar on NHibernate, a little ActiveRecord and some of the new MS OR stuff. Then I spent three days with another consulting company, showing them the ins and outs of NHibernate and sprinkling just a little WCF on the last day. In so doing, I caught myself serving out some code that I have used. Normally, I don't dish out any code here, but this might be useful to some:

 

It's a small WCF test helper that I have used to do explorative testing of WCF and even more so for integrative smoke tests of WCF services.

 

There is a zip attached that contains one vs.net 2005 project with a WCF hello world and one nunit test that runs that service. That test is an integration test, it cranks up the whole WCF machinery. Most of my WCF integration tests (all, in fact) do not test any concurrency issues. They are more simple smoke tests that everything seems to work as expected. What I usually want is to test the machinery but have one instance invoked, so that I can execute some assertions on the results using that instance afterwards.

 

Usually, you will not implement your WCF service as a singleton (although it is one of the instancing modes), for one of several reasons - scalability for example. Using the other instancing modes means that you (by default) do not control construction of your the instance that gets to serve the requests, and thus in a test situation, we do not have a reference to the instance used by WCF. One way around this is to create a custom instance provider. The instance provider in WCF (class implementing IInstanceProvider, the default being a private class in InstanceBehavior, reflect it) is responsible for supplying new service instances. I won't talk about it here, suffice it to say that my SingletonInstanceProvider simply returns one (settable) instance each time, thus making the service a singleton. It is a service behavior that we add to the servicehost description.

 

Why do this? Simply so that I can implement my service using an instancing mode that I want, but still run simple smoke tests on it. It is one solution, there are doubtless many others, if you have a better one, please give me a shout.

 

So, the testhelper or testharness that is enclosed actually does a couple of things. I won't talk about them in detail, this is roughly it:

 

  • Provide a simple way to create and start a service host and get a client to run tests against it.
  • Provide a way for tests to share services, so that the WCF machinery does not need to be restarted.
  • Get the services set up using the SingletonInstanceProvider easily
  • Allow test to access host before it is started to modify/further configure
    ( this is why you see castle in there, the client (a dynamic proxy wrapper) is actually a proxy that opens the service late/JIT )

You use it like so:

 

IMessageOfTheDay client1 = GetClient
   .For<IMessageOfTheDay>()
   .Using(new NetTcpBinding())
   .Running(serviceInstance);

 

This sets up a service host for the IMessageOfTheDay service contract, using the netTcpBinding (optional, default is named pipes since it is the fastest) and running the instance supplied. See the demotest.

 

Comments welcome. Btw, this uses my singleton implementation, I'll make a note of that tomorrow, but it's simple.

 

Questions: Has anyone seen another wcf test harness like this? I usually do all my network integration testing using some thread harness with synchronization between, and did my WCF testing in a similar (not the same) way. This harness simplified things quite a bit.

 

BTW: Most of the code is in one file; TestHelper.cs. It's a bit unwieldly, sorry, but easier to copy - you still need the singleton.cs though. I may update later if I get time.

 

Again, the download is here.

5/21/2007 2:00:04 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]  |  Trackback
 Thursday, November 16, 2006

Martin Fowler, Erik Doernenburg, James CoplienØredev 2006 is over, and it was pretty great - despite several last minute  (quite literally last day) cancellations from some high profile speakers. I talked to alot of people and many agree with me that the social atmosphere was very good. The panel on the last day rounded off the whole event nicely. In the picture you see Martin Fowler, Erik Doernenburg and James Coplien.

 

My presentation went pretty well, it seems alot of people enjoyed it. Here is the slidedeck for it.

 

I forgot a couple of things: First, I forgot to announce the next SNUG meeting, which is December 6th in Malmö - sorry chris. I also forgot to underline the steps after vou've got the code you're interested in under test. I managed to cover alot, but there are so many important ideas that I did not have time to cover.

 

The last thing I missed was the resources slide, you will find it in the download. I have also put out an older version of this talk in an older blog entry, look for it. As you probably noticed, the sessions where recorded, and I hear that there are plans to make them available to all attendees. Time will tell.

11/16/2006 11:38:48 PM (Romance Standard Time, UTC+01:00)  #    Comments [4]  |  Trackback
 Thursday, June 01, 2006

I was pleased to notice that so many had not had the opportunity to get up to speed on continuous integration before our talk yesterday. Of all the people in the auditorium only 2-3 felt they knew what all the "hoopla" is about.

Even though we could have used the full fifty minute slot, I think that we managed to cover the essence - although there is so much more there in the form of experiences and perspectives to talk about.

As promised here is the presentation slidedeck. Since it was so heavy on images I have made them smaller, although this download is still large (6mb).

Links to good articles - the web is naturally full of both good and bad, but don't miss these:

On the conference:
We had a great time at Developer Summit 2006 in Kista, Stockholm. I applaud all the great guys and gals at Cornerstone for managing to create such a cozy gathering!

The first day started out with an interesting overview of mashups and the semantic web. Erik did a great top 10 developer donts kind of thing that I enjoyed very much - highlighting best practices, many of which are reexposed in agile. After lunch, Jimmy did TDD and we got a nice agile progression going upto my CI talk. The second day highlights for me was probably Manges entertaining causerie on Web 2.0 and an entertaining overview of open source development in .NET by Mats Helander. Patrik did WF and Johan a potpourri of coming VS.NET stuff.


Lets hope we get the same kind of event next year. For more conference and development fun this year, keep your eye on Öredev scheduled for November.


6/1/2006 11:07:25 AM (Romance Daylight Time, UTC+02:00)  #    Comments [0]  |  Trackback
 Monday, May 22, 2006

If you are migrating to VS.NET 2005 and converting projects, the VS.NET conversion wizard will do that for you. Then you can use MSBee to compile into both 1.1 and 2.0 assemblies.

 

However, if you are migrating the build process perhaps before all projects in your organization have migrated, people will still be developing in VS.NET 2003 for some time, yet you want to have a standardized build process, around MSBuild.

 

This little MSBuild task will convert a VS.NET 2003 project on the fly so that you can use MSBuild to compile it.

 

Pretty niche scenario, yet since I found myself there, others probably will too.

 

It is easy to use, you just slap a Using element and then use the task, giving it the projects name. Thats it. Installation is xcopy. The readme gives step-by-step instructions. Happy building!

ConvertTo2005.zip (10.87 KB)
5/22/2006 2:28:46 PM (Romance Daylight Time, UTC+02:00)  #    Comments [1]  |  Trackback
 Monday, December 19, 2005
For those that attended my generics talk at either Öredev in November or the SNUG meeting last monday, the presentation is available in powerpoint format from www.dotway.se, at this downloads page.

12/19/2005 8:08:18 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]  |  Trackback