【问题标题】:BizTalk database lookup functoid - Unit TestingBizTalk 数据库查找 functoid - 单元测试
【发布时间】:2015-09-01 08:33:18
【问题描述】:
【问题讨论】:
标签:
unit-testing
biztalk
biztalk-2013
【解决方案1】:
编辑:我第一次尝试回答没有奏效。这个可以。
我的 BizTalk VM 上只有 VS 2010,所以这适用于 Moles,但我希望它应该与 Fakes 相同。它直接执行 xslt 转换并用绕行(填充)的对象集合覆盖扩展对象集合。这里的 Moled 程序集是“C:\Program Files (x86)\Microsoft BizTalk Server 2010\Developer Tools\Microsoft.BizTalk.BaseFunctoids.dll”。
var inputStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("TestProject.TestFile.xml");
XPathDocument xpath = new XPathDocument(inputStream);
var myFunctoids = new Microsoft.BizTalk.BaseFunctoids.Moles.MFunctoidScripts();
myFunctoids.DBLookupInt32StringStringStringString = (a, b, c, d, e) => "1";
myFunctoids.DBValueExtractInt32String = (a, b) => "result";
myFunctoids.DBLookupShutdown = () => "";
XsltArgumentList extensionObjects = new XsltArgumentList();
extensionObjects.AddExtensionObject("http://schemas.microsoft.com/BizTalk/2003/ScriptNS0",
myFunctoids.Instance);
var outputStream = new MemoryStream();
var myMap = (Microsoft.XLANGs.BaseTypes.TransformBase)new Map1();
myMap.Transform.Transform(xpath, extensionObjects, outputStream);
outputStream.Position = 0;
Assert.AreEqual("<expected>result</expected>", new StreamReader(outputStream).ReadToEnd());