I've been tweaking the PipelineTesting API further as I use it and write the unit tests for it. Here are some of the improvements I've made on the pipeline creation syntax:

  1. The NewReceive()/NewSend() methods were renamed to just Receive() and Send(), across all creation functions. This leads to a slightly shorter and more readable (imho) syntax.
  2. The End() method in the builder classes is now optional; as they now provide an implicit conversion operator to ReceivePipelineWrapper and SendPipelineWrapper respectively. I think this is one change that was really needed to make the syntax more palatable, and means you can now do this:
ReceivePipelineWrapper pipeline = Pipelines.Receive()
.AddValidator(new XmlValidator());

I think this looks much better.

Creating standard components

One of the problems with the current PipelineTesting version is that while it allows you to use one of the standard assembler/disassembler components on an empty pipeline, it provides no help doing so. Using them can be pretty annoying because there's no easy way to add document and envelope schemas.

The cause for this is that the relevant properties in the standard Xml/FF assembler and disassembler components use types defined in Microsoft.BizTalk.Component.Utilities.dll. The types themselves are public (and even somewhat documented), but the assembly can only be found in the GAC, which means referencing it in tests projects is a pain in the neck.

To save yourself the trouble from having to do this, the new PipelineTesting API will also expose classes to make it easier to create and configure the standard XML and Flat File assembler and disassembler components. Here's an example of the syntax I'm implementing:

XmlAssembler asm = Assembler.Xml()
.WithDocumentSpec()
.WithEnvelopeSpec()
.WithPreserveBom(true);
SendPipelineWrapper pipeline = Pipelines.Send()
.AddAssembler(asm);
// ...

Technorati tags: ,


Tomas Restrepo

Software developer located in Colombia.