6.7. Invoking Workflows

WF4 offers the ability to invoke individual activities without using the workflow runtime. This could be used for scenarios such as unit testing. However, as many workflows will run for a long time, this won't be useful in all instances.

We will now invoke the workflow we created previously and check that requesting ten tickets returns the variable BookingSuccessful set to false. Note that in reality you would write this as a unit test with a framework such as NUnit, but we are just covering the principles here.

  1. Add a new C# console project to the solution called Chapter6.HelloWF.Tests.

  2. Add a reference to System.Activities and Chapter6.HelloWF.

  3. Enter the following using statements in Program.cs:

    using System.Activities; ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.