尝试在 Visual Studio 2019 中对 BizTalk 2020 工件进行单元测试时遇到问题。
以下是我遵循的步骤:
- 我创建新的空 BizTalk 项目“测试”并将其配置为在项目属性中进行单元测试。
- 我在名为“管道”的项目中创建了一个文件夹
- 在这个文件夹中,我创建了一个带有单个“XML 反汇编器”组件的接收管道“ppr_Testing.btp”。
- 我创建了新的单元测试项目“_Test”
- 在“_Test”项目中,我添加了对“Testing”的项目引用
- 在单元测试项目中,我创建了一个单元测试并尝试编写代码来实例化“ppr_Testing”管道
using Testing.Pipelines;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace _Test
{
/// <summary>
///This is a test class for Test_ppr_Testing and is intended
///to contain all Test_ppr_Testing Unit Tests
///</summary>
[TestClass()]
public class Test_ppr_Testing
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
/// <summary>
///A test for ppr_Testing Constructor
///</summary>
[TestMethod()]
public void Test_ppr_TestingConstructor()
{
ppr_Testing target = new ppr_Testing();
var lDocuments = new System.Collections.Specialized.StringCollection();
lDocuments.Add(@"C:\MyTestDirectory\SomeFile.xml");
var lParts = new System.Collections.Specialized.StringCollection();
var lSchemas = new System.Collections.Generic.Dictionary<string, string>();
try
{
target.TestPipeline(lDocuments, lParts, lSchemas);
var lTmp = this.TestContext;
}
catch (Exception ex)
{
Assert.Fail(ex.ToString());
}
}
}
}
结果 :
- 代码有错误下划线,因为 Intellisense 无法识别该对象
- 如果我设法在没有 Intellisense 的情况下编写测试代码,它将成功编译并运行
我做错了什么,还是我的 Visual Studio 2019 安装已损坏?
我正在从 BizTalk 2010 迁移到 BizTalk 2020,并且使用 BizTalk 2010 和 Visual Studio 2010 事情变得更容易:
- 我只是转到“测试”菜单,“新建测试...”,然后是“单元测试向导”,然后按照向导进行操作,一切正常。
提前感谢您的帮助。