Set Unit attribute of property / setting RunTime

I am wondering if it is possible to set / change the Unit of a property / setting of a TestStep at RunTime.

We have some blocks that are generic in their Unit, but we would like to be able to log, visualize and propagate whatever Unit the Input value has.

I know that you can access the Unit of a connected Output through:

if (input.Property != null)
    if (input.Property.HasAttribute<UnitAttribute>())
        Log.Debug("Unit of input is: '{ 0}'", input.Property.GetAttribute<UnitAttribute>().Unit);

but it kinda stops there if I am unable to set the Unit of another field accordingly.

For example, we have a generic Math test step, that can add, subtract, multiply and divide two Inputs and put the result in an Output field. I would like to propagate the Input Unit to its Output, so it will be available in subsequent steps, and will show correctly in the GUI and also when I publish results.

1 Like