How to use InputOutputRelation.Assign

My goal is to have a more complex test step based on a set of simpeler test steps. I programmatically add the simple steps as children and want to link their inputs/outputs.
The API refference mentions the following:

https://doc.opentap.io/api/class_open_tap_1_1_input_output_relation.html
InputOutputRelation.Assign(ITestStepParent inputObject, IMemberData inputMember, ITestStepParent outputObject, IMemberData outputMember)

When trying to apply this i cant find the IMemberData of the outputMember.

Example
I created a teststep called MessageCreator with the following output:

[Output]
public string Message { get; set; }

I created a teststep called MessageReceiver with the following Input:

[Display("Message")]
public Input<string> Message { get; set; }

Then i make a teststep where i programatically add those steps as children, this all works fine :ok_hand:

var creator= new MessageCreator();
ChildTestSteps.Add(creator);

var receiver = new MessageReceiver();
ChildTestSteps.Add(receiver);

Now i want to assign the creator output to the receiver input but i can’t figure out to get the IMemberData of an output:

InputOutputRelation.Assign(receiver, receiver.Message.Property, creator, ??? );

Apart from the API doc on this i can’t find anything on this topic in the documentation/forum.

InputOutputRelation does not work with Input<T> You have two options.

If you keep Input<T>, you have to do:

receiver.Message.Property = TypeData.GetTypeData(creator).GetMember("Message");
receiver.Message.Step = creator;

Alternatively, use InputOutputRelation.

// Modify MessageCreator
[Display("Message")]
public string Message { get; set; }

// now in the constructor:
InputOutputRelation.Assign(receiver, 
   TypeData.GetTypeData(receiver).GetMember("Message"), 
   creator, 
   TypeData.GetTypeData(creator).GetMember("Message"),
   );
2 Likes

Thanks for the quick reply.

So, correct me if i’m wrong:

  • The first solution uses input/output properties (does it need to be output or can it be any property?)
  • The second one works with any regular public properties.
  • Both ways are dynamic, as in, the property in the receiver will be updated when the property in the creator is updated on runtime.
1 Like
  1. In theory it does not have to be an [output] property, but that might be confusing for the user, since they can only select output properties for their inputs.
  2. Yes, as of OpenTAP 9.16 or so any setting can be regarded as an input. So you can assign any [output] to it.
  3. More or less. For (1) The value is updated ‘on read’ and for (2) the value is updated right before the ‘reader’ test step is executed.
1 Like