mardi 3 mars 2015

An extension of type 'Microsoft.Activities.UnitTesting.Stubs.IMessagingStub' must be configured in order to run this workflow

I have a workflow service and I need run unit test for workflow service


Here is code:



[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

}
}


So when I run debug UnitTest, I receive an error message at line "using (host = WorkflowServiceTestHost.Open(mockedService, _serviceAddress))":


Here is error:


"Test method StartWorkFlow threw exception: System.Activities.ValidationException: An extension of type 'Microsoft.Activities.UnitTesting.Stubs.IMessagingStub' must be configured in order to run this workflow."


I don't know why I receive that error.


Can someone show me the right code for it to work?


Aucun commentaire:

Enregistrer un commentaire