C# 必须配置“Microsoft.Activities.UnitTesting.Stubs.IMessagingStub”类型的扩展才能运行此工作流
我有一个工作流服务,我需要为工作流服务运行单元测试 以下是代码:C# 必须配置“Microsoft.Activities.UnitTesting.Stubs.IMessagingStub”类型的扩展才能运行此工作流,c#,unit-testing,workflow-foundation-4,workflowservice,C#,Unit Testing,Workflow Foundation 4,Workflowservice,我有一个工作流服务,我需要为工作流服务运行单元测试 以下是代码: [TestClass] public class WorkflowServiceTest { private readonly Binding _binding = new NetNamedPipeBinding(); private readonly EndpointAddress _serviceAddress = new EndpointAddress("net.pipe://localhost/Workfl
[TestClass]
public class WorkflowServiceTest
{
private readonly Binding _binding = new NetNamedPipeBinding();
private readonly EndpointAddress _serviceAddress = new EndpointAddress("net.pipe://localhost/WorkflowService");
[TestMethod]
[DeploymentItem(@"WorkflowServices\WorkflowService.xamlx")]
public void StartWorkFlow()
{
#region Test 2
var xamlInjector = new XamlInjector("WorkflowService.xamlx");
xamlInjector.ReplaceAll
(typeof(ExecutePofolioControllerActivityAsync), typeof(MockExecutePofolioControllerActivityAsync));
xamlInjector.ReplaceAll
(typeof (GetPortfolioControllerStatusActivity), typeof (MockGetPortfolioControllerStatusActivity));
xamlInjector.ReplaceAll(typeof (GetTraderStatusesActivity), typeof (MockGetTraderStatusesActivity));
xamlInjector.ReplaceAll(typeof(Delay),typeof(DelayStub));
xamlInjector.ReplaceAll(typeof(Receive), typeof(ReceiveStub));
xamlInjector.ReplaceAll(typeof(SendReply), typeof(SendReplyStub));
// Then we load the service and replace the activities with mocks
var mockedService = xamlInjector.GetWorkflowService();
DelayStub.StubDuration = TimeSpan.FromSeconds(10);
WorkflowServiceTestHost host = null;
try
{
// Host the service
using (host = WorkflowServiceTestHost.Open(mockedService, _serviceAddress))
{
// Setup a proxy to use named pipes
var proxy = new WorkflowServiceClient(this._binding, this._serviceAddress);
var serviceTask = new ServiceTask
{
UserId = ValidId,
TaskType = TaskType.Start,
IssuerName = "UserTest",
};
proxy.Start(serviceTask);
}
}
finally
{
if (host != null)
{
host.Tracking.Trace();
}
}
#endregion
}
}
因此,当我运行debug UnitTest时,我在第行使用host=WorkflowServiceTestHost.OpenmockedService,_serviceAddress:
以下是错误:
试验方法
StartWorkFlow引发异常:
System.Activities.ValidationException:必须配置“Microsoft.Activities.UnitTesting.Stubs.IMessagingStub”类型的扩展才能运行此工作流
我不知道为什么我会收到那个错误
有人能告诉我正确的代码吗?1创建IMessagingStub的实现2将其添加到工作流服务扩展3修复程序errors@Will:我们如何用上面的代码创建IMessagingStub的实现,我试着研究了一下,但还是没有找到,你能给我一个示例代码吗?没有。我不知道。从公共类MessagingStub开始:IMessagingStub。