相关阅读:
前面几篇介绍了如何对Activity进行状态测试,行为测试,及Mock Object Framework的使用。当然,仅仅测试Activity是不够的,我们最终还要对整个Workflow进行测试。这一篇就为大家讲一下如何对 Workflow进行测试。
在上一篇的NewEmployeeWFLibrary工程里,添加一个名为StoreNewAcmeEmployee的顺序工作流。为工作流添加三个属性和一个事件:
public string FirstName { get; set; } public AcmeEmployee NewEmployee { get; set; } |
我们设定这个工作流的功能是根据给定的FirstName和LastName生成一个AcmeEmployee对象。下面我们开始写测试代码。在测试工程中添加一个测试类ProvisionNewEmployee_WorkflowShould,代码如下:
[TestClass] [TestInitialize] // Add the scheduler to the _runtime before it is started // when the workflow completes, assign the output value to a test ArgumentNullException("o"); e.OutputParameters["NewEmployee"]; // this event will fire if an exception occurs in the runtime. // The WF runtime wants to manage exceptions here all by itself }); [TestMethod] Mother.CreateNewAcmeEmployee()); [TestMethod] [TestMethod] private void RunTheWorkflow(string firstName, string lastName) WorkflowInstance targetWorkflow = _runtime.CreateWorkflow(typeof(ProvisionNewEmployee), args); _manualScheduler.RunWorkflow(targetWorkflow.InstanceId); |