Testing a WF program with a unit test framework
In this task, we will create a Test Project to do unit testing for a WF program.
How to do it...
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Activities;
namespace UnitTestForWFProgram
{
[TestClass]
public class UnitTest1
[TestMethod]
public void TestMethod1()
var output =
WorkflowInvoker.Invoke(new WorkflowForTest());
Assert.AreEqual("Test Message",
output["OutMessage"]);
}
How it works...
In the preceding code snippet, [TestClass] indicates it is a unit test class, whereas [TestMethod] indicates a test method. When the Test Project runs, the test method will be executed automatically.
There's more...
In real application development, we can also create a separate Unit Test project and add a reference to the target project.