lundi 26 janvier 2015

Biztalk Map Unit Testing Exception

I am trying to unit test a map with following code,



protected string Map(TransformBase map, string xml)
{
StringWriter str = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(str);

map.Transform.Transform(new XPathDocument(new StringReader(xml)), new XsltArgumentList(), writer);

return str.ToString();
}


And it's invoked as follows,



[Test]
public void Map_Test()
{
var result = Map(new TestMap(),File.ReadAllText(_dataDir.GetFiles("TestRequest.xml")[0].FullName));
Assert.IsTrue(result.Contains("4323432"));
}


This works fine for most of the maps, however if I uses a function from an external assembly, this does not works and fails with the error



Result Message: System.Xml.Xsl.XslTransformException : Cannot find a script or an extension object associated with namespace 'http://ift.tt/15ENNY6'.

Result StackTrace:
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at <xsl:template match="/workOrderRequest">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
at <xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(XmlReader input, XsltArgumentList arguments, XmlWriter results)

Aucun commentaire:

Enregistrer un commentaire