Skip to content
tomasr edited this page Sep 12, 2010 · 1 revision

It is possible to target BizTalk schemas in your testing efforts using all versions of PipelineTesting if you don’t mind doing a little bit of grunt work. This is possible for both flat file and xml schemas, and is done simply by instantiating a pipeline (either a compiled pipeline or by creating a new one from scratch) and then running your instance documents through it and checking the output.

This works particularly well for advanced scenarios involving envelopes or batching/debatching, but it’s overkill for the simple scenarios.

Beginning with PipelineTesting v1.2.1.0, there’s a new feature for easy testing of schemas in those simple scenarios. Partially inspired by the new functionality offered in BizTalk Server 2009, the SchemaTester<T> class allows you to parse/assemble a document according to a single document schema with a single method call.

To use SchemaTester<T>, simply provide the type of the BizTalk schema to use and call one of it’s static methods. The options offered are:

  • ParseFF: Parses a flat file into an XML document
  • ParseXml: Parses an XML document
  • AssembleFF: Assembles an XML document into a new flat file
  • AssembleXml: Assembles an XML document

All method come with overloads that use streams or paths to files. Here’s an example of how to use it based on one of the unit tests for this feature:


Stream input = DocLoader.LoadStream("CSV_FF_RecvInput.txt");
Stream output = SchemaTester<Schema3_FF>.ParseFF(input);
// Load resulting XML document
XmlDocument doc = new XmlDocument();
doc.Load(output);

If the document cannot be converted, an exception will be raised. Remember that you must consume the resulting stream (if using the stream-variants of the SchemaTester<T> methods). You can then check the resulting exception to look into why the parsing/assembling is failure.

To make it easier to deal with the different parsing exceptions, and how to extract meaningful information out of it, you can use the ErrorHelper.GetErrorMessage() helper method.