Question

Problem

I'm trying to create an array of containers in c# to pass back to TestStand as test results, and there doesn't appear to be an easy way to accomplish this task.

Motivation

In c# I have results contained in List<Dictionary<string,object>> from my test system and I'd like to have those results show up in my test report. The Dictionary<string,object> has a variable number of elements of different types.

Attempted Solutions

If given:

var result = sequenceContext.AsPropertyObject().EvaluateEx(destination, EvaluationOptions.EvalOption_NoOptions);

Where

  • sequenceContext is NationalInstruments.TestStand.Interop.API.SequenceContext
  • destination is where I'd like my results to be saved in my TestStand report, i.e. Step.Result.TestResultDestination

I've tried a few different methods to add an array of containers to result, such as:

var newPropertyObject = sequenceContext.Engine.NewPropertyObject(PropertyValueTypes.PropValType_Container, true, string.Empty, PropertyOptions.PropOption_InsertIfMissing);
result.SetPropertyObject("TestResultDestination", PropertyOptions.PropOption_InsertIfMissing, newPropertyObject);
result.SetFlags("TestResultDestination", PropertyOptions.PropOption_NoOptions, PropertyFlags.PropFlags_IncludeInReport | PropertyFlags.PropFlags_IsMeasurementValue);

Which adds the array of containers to my result, however any attempt to then insert an element into the array of containers results in an exception.

Thoughts?

Was it helpful?

Solution

I was close, I was missing a few key steps:

 if (!result.Exists("TestResultDestination", 0))
 {
       //once we have added this element do not add it again, it will overwrite the other array elements
       var newPropertyObject = sequenceContext.Engine.NewPropertyObject(PropertyValueTypes.PropValType_Container, true, string.Empty, PropertyOptions.PropOption_InsertIfMissing);
       //for my example I only need 5 elements, set the dimension of the array                                        
       newPropertyObject.SetNumElements(5, 0);
       result.SetPropertyObject("TestResultDestination", PropertyOptions.PropOption_InsertIfMissing, newPropertyObject);
       result.SetFlags(newKey, PropertyOptions.PropOption_NoOptions, PropertyFlags.PropFlags_IncludeInReport | PropertyFlags.PropFlags_IsMeasurementValue);
  }

One can then proceed to work with an element in the array by using array syntax, i.e. TestResultDestination[0] to store the actual results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top