Posts Tagged ‘test workflow’

WorkflowInvoker class provides a means for invoking a workflow as if it were a method call.

Namespace:System.Activities
Assembly:System.Activities (in System.Activities.dll)

A custom activity example which we will call using WorkFlowInvoker :

public sealed class SendEmailActivity : CodeActivity
{

[RequiredArgument]
public InArgument Subject { get; set; }

[RequiredArgument]
public InArgument Body { get; set; }

[RequiredArgument]
public InArgument To { get; set; }

[RequiredArgument]
public InArgument From { get; set; }

protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Subject input argument
string text = context.GetValue(this.Subject);
}
}

Invokes SendEmailActivity :
public void TestSendEmailActivity()
{

WorkflowInvoker invoker = new WorkflowInvoker(
new SendEmailActivity
{
From = "Anupama_roy@testmail.com",
To = "Anupama_roy@testmail.com",
Subject = "Hello",
Body="How are you?"

});

invoker.Invoke();

}