As I mentioned on a previous
, I've been working on a helper library to test BizTalk Pipelines and
Custom Pipeline Components using NUnit or your unit testing framework of choice.
I've uploaded V1.0 of the library, which you can download from here.

The library is pretty straightforward to use, but I'm going to document its
features on this and following posts so that you can get started with it

Preparing to use the library

First of all, you'll need to build the library from the downloaded source
code distribution, using Visual Studio 2005. The distribution includes the unit
tests for the library, which you can run to verify it is working correctly, if
you want.

To use the library once you've built it, you'll want your projects to
reference the following three libraries:

  • Winterdom.BizTalk.PipelineTesting.dll
  • Microsoft.BizTalk.Pipeline.dll
  • Microsoft.BizTalk.Pipeline.Components.dll

Creating Pipelines

To test a pipeline component, or a pipeline, the first thing you'll need to
do pretty much is instantiate a pipeline. The library supports two different
ways of doing this: Create an empty pipeline and add the necessary components
using code, or create an instance of an existing BizTalk pipeline. Both of these
operations are supported for send and receive pipelines through the methods in
the PipelineFactory class.

  • CreateEmptyReceivePipeline() and CreateEmptySendPipeline() create a new
    receive or send pipeline respectively, that has no components configured
    on any of its stages. You then are responsable for adding the necessary
    components to configure your pipeline as necessary; I'll show later how this
    can be done.

    Here's an example of how these methods can be called:

    sendPipeline =


    receivePipeline =


  • CreateReceivePipeline() and CreateSendPipeline() create a new instance of
    an existing BizTalk pipeline. Each of these methods take a Type handle as an
    argument. When you compile a BizTalk project that contains a pipeline, said
    pipeline is generated as a new CLR type into your BizTalk assembly (with the
    same name as the .BTP file it is derived from).

    This is very convenient, as it allows you to just add a project or file
    reference to the BizTalk project where you designed the pipeline and use the
    type directly. In fact, built-in pipelines like the XMLTransmit or XMLReceive
    pipeline can be used just this way: simply reference the
    Microsoft.BizTalk.DefaultPipelines.dll assembly and write this:



    receivePipeline =



Configuring Components

If you've created an instance of an existing pipeline, you've probably
set to go and can skip this part (though you can still add new components to an
existing pipeline this way), if not, you'll now want to add some components to
each of the stages you're interested in to your pipeline.

To do this, you can use the AddComponent() method of each of the pipeline
classes, which take an object implementing IBaseComponent (a pipeline component)
and an object of type PipelineStage representing the stage you want to add that
component to. The PipelineStage class contains a set of static readonly objects
you can use to refer to the possible stages you can use, so you'll never create
an instance of this type directly.

So, for example, if you want to add a new XML Disassembler component to the
disassemble stage of a receive pipeline, you can write this:

pipeline =


component = new XmlDasmComp();

pipeline.AddComponent(component, PipelineStage.Disassemble);


Here's an example of adding an encoding component to a send pipeline:

pipeline =


encoder = new

encoder.AddSigningCertToMessage = true;

encoder.ContentTransferEncoding =


encoder.EnableEncryption =

pipeline.AddComponent(encoder, PipelineStage.Encode);


In a following post I'll talk about configuring document specifications
(schemas) and executing the pipelines.

Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.