<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;It is possible to target BizTalk schemas in your testing efforts using all versions of PipelineTesting if you don&amp;#8217;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.&lt;/p&gt;
&lt;p&gt;This works particularly well for advanced scenarios involving envelopes or batching/debatching, but it&amp;#8217;s overkill for the simple scenarios.&lt;/p&gt;
&lt;p&gt;Beginning with PipelineTesting v1.2.1.0,  there&amp;#8217;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 &lt;code&gt;SchemaTester&amp;lt;T&amp;gt;&lt;/code&gt; class allows you to parse/assemble a document according to a single document schema with a single method call.&lt;/p&gt;
&lt;p&gt;To use &lt;code&gt;SchemaTester&amp;lt;T&amp;gt;&lt;/code&gt;, simply provide the type of the BizTalk schema to use and call one of it&amp;#8217;s static methods. The options offered are:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;ParseFF: Parses a flat file into an &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; document&lt;/li&gt;
	&lt;li&gt;ParseXml: Parses an &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; document&lt;/li&gt;
	&lt;li&gt;AssembleFF: Assembles an &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; document into a new flat file&lt;/li&gt;
	&lt;li&gt;AssembleXml: Assembles an &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt; document&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All method come with overloads that use streams or paths to files. Here&amp;#8217;s an example of how to use it based on one of the unit tests for this feature:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
Stream input = DocLoader.LoadStream(&quot;CSV_FF_RecvInput.txt&quot;);
Stream output = SchemaTester&amp;lt;Schema3_FF&amp;gt;.ParseFF(input);
// Load resulting XML document
XmlDocument doc = new XmlDocument();
doc.Load(output);
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;If the document cannot be converted, an exception will be raised. Remember that you &lt;strong&gt;must&lt;/strong&gt; consume the resulting stream (if using the stream-variants of the &lt;code&gt;SchemaTester&amp;lt;T&amp;gt;&lt;/code&gt; methods). You can then check the resulting exception to look into why the parsing/assembling is failure.&lt;/p&gt;
&lt;p&gt;To make it easier to deal with the different parsing exceptions, and how to extract meaningful information out of it, you can use the &lt;code&gt;ErrorHelper.GetErrorMessage()&lt;/code&gt; helper method.&lt;/p&gt;</body>
  <created-at type="datetime">2009-11-22T23:54:48-08:00</created-at>
  <id type="integer">114373</id>
  <permalink>testing-schemas</permalink>
  <repository-id type="integer">33740</repository-id>
  <title>Testing Schemas</title>
  <updated-at type="datetime">2009-01-14T18:24:41-08:00</updated-at>
  <user-id type="integer">16179</user-id>
</wiki>
