A while back in my series of articles about testing with BizTalk I covered a technique for testing pipelines and pipeline components. The background to the approach is still valid in BizTalk 2009, but the technique is improved. To review the previous article refer to the following link:

Pipeline Components – http://geekswithblogs.net/michaelstephenson/archive/2008/03/30/120852.aspx

Pipelines – http://geekswithblogs.net/michaelstephenson/archive/2008/03/30/120853.aspx

In this post although we could do testing of pipelines and pipelines components using the excellent pipeline component test library. While that component is excellent for testing, I think the new model provides a simpler option and to be honest with Pipeline Component Test Library it sometimes took a little bit of fiddling with setting up the pipeline wrappers to get your test to work. My gut feeling is that the new approach will just be that bit more straightforward.

I will extend on the sample from the previous post about testing schemas. So our solution now looks like the below picture containing a pipeline

  1. Configure your BizTalk Project for Tests

Just to reiterate this step from the previous post you need to ensure the enable unit testing property is set for the BizTalk project.

  1. Adding references to your test assembly

Again reiterating this step, in your test project you will need to add a couple of references, the main one is the new Microsoft.BizTalk.TestTools assembly which is in the Visual Studio Add Reference list. This will allow you to use these new testing features. You would also need to add references to the pipeline assemblies highlighted in the below picture

  1. The test code

In the below code you can see that I will construct an instance of the TestableReceivePipeline which is what my custom receive pipeline will derive from. I can then provide documents and schema information and then execute my pipeline. Unfortunately the documentation of these objects doesn’t seem to be complete in the initial CTP so Im guessing there are a few more ways you can configure these objects, but they will give you an easy way to test send and receive pipelines.

  1. What about Pipeline Components

In the Pipeline Component Test Library there was the ability to be able to construct a pipeline wrapper in code so you could simulate adding your custom pipeline component to different types of pipeline. I’m not sure that you can do this in the new features of BizTalk 2009, however you can just create a pipeline artefact and add your component to that. The other cool feature is you might not (haven’t tried this) even have to add a new project for the BizTalk artefact as you can have BizTalk and C# files in the same project.

Summary

As you can see this new technique appears like it will be a simpler way to encourage testing.

The sample for this demo is available at the following location: http://www.box.net/shared/7rb81bcxsm

If you have problems accessing it then let me know.