/// <summary> /// Tests the map. /// </summary> /// <param name="map">The map to execute.</param> /// <param name="xsltExtensionObjectOverrides">The overrides for the XSLT arguments - allowing you to mock external assembly methods.</param> /// <param name="validateInputXml">if set to <c>true</c> then the input XML is validated.</param> /// <param name="validateOutputXml">if set to <c>true</c> then the output XML is validated.</param> public void TestMap(TransformBase map, IEnumerable <XsltExtensionObjectDescriptor> xsltExtensionObjectOverrides, bool validateInputXml, bool validateOutputXml) { if (map == null) { throw new ArgumentNullException(nameof(map)); } if (validateInputXml) { BizTalkXmlMapTestValidator.ValidateInputXml(map, this.InputXml, this.Logger); } this.logger.Log("Executing the BizTalk map (XML to XML) " + map.GetType().Name); string outputXml = BizTalkXmlMapExecutor.PerformTransform(map, xsltExtensionObjectOverrides, this.InputXml); this.logAssert.IsTrue("XML output from the BizTalk map exists", !string.IsNullOrWhiteSpace(outputXml)); this.logger.Log(); this.logger.Log("BizTalk map (XML to XML) execution completed"); base.SetActualOutputXmlFromXmlString(outputXml); if (validateOutputXml) { BizTalkXmlMapTestValidator.ValidateOutputXml(map, this.ActualOutputXml, this.Logger); } }
/// <summary> /// Tests the map. /// </summary> /// <param name="map">The map to execute.</param> /// <param name="xsltExtensionObjectOverrides">The overrides for the XSLT arguments - allowing you to mock external assembly methods.</param> /// <param name="validateInput">if set to <c>true</c> then the input flat file contents and converted XML is validated.</param> /// <param name="validateOutput">if set to <c>true</c> then the output is validated.</param> public void TestMap(TransformBase map, IEnumerable <XsltExtensionObjectDescriptor> xsltExtensionObjectOverrides, bool validateInput, bool validateOutput) { if (map == null) { throw new ArgumentNullException(nameof(map)); } XNode inputXml = BizTalkXmlFlatFileAdapter.ConvertInputFlatFileContentsToInputXml(map, this.InputFlatFileContents); if (validateInput) { BizTalkXmlMapTestValidator.ValidateInputXml(map, inputXml, this.Logger); } Logger.Log("Executing the BizTalk map (flat file to flat file) " + map.GetType().Name); string outputXmlString = BizTalkXmlMapExecutor.PerformTransform(map, xsltExtensionObjectOverrides, inputXml); LogAssert.IsTrue("XML output from the BizTalk map exists", !string.IsNullOrWhiteSpace(outputXmlString)); var actualOutputXml = XElement.Parse(outputXmlString); if (validateOutput) { BizTalkXmlMapTestValidator.ValidateOutputXml(map, actualOutputXml, this.Logger); } var schemaTree = BizTalkMapSchemaUtility.CreateSchemaTreeAndLoadSchema(map, map.TargetSchemas[0]); if (schemaTree.IsStandardXML) { throw new InvalidOperationException("The map does not have a schema for converting to a flat file."); } else { Logger.Log("Converting the XML output of the BizTalk map to a flat file"); this.ActualOutputFlatFileContents = BizTalkXmlFlatFileAdapter.ConvertOutputXmlToOutputFlatFileContents(map, actualOutputXml, validateOutput); } Logger.Log(); Logger.Log("BizTalk map (flat file to flat file) execution completed"); }