« Custom Controls in WPF | Main | Martyn Lovell on the Secure CRT »
As I mentioned on a previous post, 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 easily.
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:
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.
Here's an example of how these methods can be called:
SendPipelineWrapper sendPipeline =
PipelineFactory.CreateEmptySendPipeline();
ReceivePipelineWrapper receivePipeline =
PipelineFactory.CreateReceivePipeline(typeof(XMLReceive));
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:
using Microsoft.BizTalk.DefaultPipelines;
// ...
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:
ReceivePipelineWrapper pipeline =
PipelineFactory.CreateEmptyReceivePipeline();
IBaseComponent component = new XmlDasmComp();
pipeline.AddComponent(component, PipelineStage.Disassemble);
Here's an example of adding an encoding component to a send pipeline:
SendPipelineWrapper pipeline =
MIME_SMIME_Encoder encoder = new MIME_SMIME_Encoder();
encoder.AddSigningCertToMessage = true;
encoder.ContentTransferEncoding =
MIME_SMIME_Encoder.MIMETransferEncodingType.Base64;
encoder.EnableEncryption = true;
pipeline.AddComponent(encoder, PipelineStage.Encode);
In a following post I'll talk about configuring document specifications (schemas) and executing the pipelines.
Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...
email: tomas@winterdom.com msn: tomasr@passport.com
Copyright © 2002-2008, Tomas Restrepo.
Powered by: newtelligence dasBlog 2.2.8279.16125