Search code examples
workflow-foundation-4

WF 4 Unit Testing - OverloadGroup Validation


I have unit tests to run my code as follows:

             MyActivity myActivity = new MyActivity ()
            {
                Input1 = "value1"
            };

            WorkflowInvoker.Invoke(myActivity);
            /// do assert

MyActivity also has Input2 as an InArgument. The problem I am having is that Input1 and Input2 have validaiton arguments as follows.

[OverloadGroup("Input1")]
[RequiredArgument]
public InArgument<string> Input1{ get; set; }

[OverloadGroup("Input2")]
[RequiredArgument]
public InArgument<string> Input2{ get; set; }

This is because I only want one value required.

I am receiving the following error :

The root activity's argument settings are incorrect. Either fix the workflow definition or supply input values to fix these errors: 'MyActivity': The following overload groups are configured: Input1, Input2. Only one overload group should have its arguments configured. Parameter name: program

I am not sure what I am doing wrong as I did just set just one of the 2 activities?
Perhaps there is a better way to unit test the WFs.
The activity does work correctly when called normally inside a workflow service.

Any assistance would be greatly appreciated.


Solution

  • I managed to 'solve' it by wrapping the activity inside a sequence and then invoking the sequence activity.