我正在为BizTalk实施单元测试。
我可以对BizTalk Maps进行单元测试,只要它不包含Database Lookup
等外部functoid。
有没有办法伪造Database Lookup
functoid,以便我可以正确地测试我的BizTalk地图?
我在data
attributes上尝试过提议的解决方案,但没有成功。
我也试图找到一种方法来使用Microsoft Fakes
,但我无法找到我需要假装的组件。
答案 0 :(得分:0)
编辑:我的第一次尝试回答没有用。这个。
我的BizTalk VM上只有VS 2010,所以这是Moles,但它应该与Fakes一样,我希望如此。它直接执行xslt变换,并使用绕道(shimmed)变换覆盖扩展对象集合。这里的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());