09-08-2008 06:02 AM
Hello,
I am using using a C# dll in which there is some functions use enumerated data type define in same dll. I need to test that function for all enumerated values. For this, I want to create local variable array of enum type which has all the values of the enumerated data type and then using for loop and enum type variable I can iterate through that array for whole enum range.
I can do this by using int variable also but then I will not be able to retrieve the string value of the enum or it may be the case that enum integer value are not in serial order.
So can you help me how can I use enum?
09-09-2008 03:15 AM
09-10-2008 12:51 PM
goel,
I think that you are handling the enums correctly and in the best method available via TestStand. Since enums are not a native TestStand type we cannot directly import this information into TestStand. The best way to handle them is to use the integer indices to pass the information back and forth (which is what you seem to be doing). The only other thing we could do to better represent the enum within TestStand is to build an array of strings (our enum values) and then map the indices of that array to the integer values of our enum. This would create holes if you didn't have a serial order, but it could help to manipulate the data from within TestStand.
09-10-2008 01:37 PM - edited 09-10-2008 01:42 PM
goel,
I overlooked a second way we can create an enum in TestStand. We can create a container of numbers, and then each numeric element in the container will hold the integer value of our enum element. Thus we can use non-serial enums since we can name the elements consecutively (as show below) but the values stored are nonconsecutive integers to represent the actual enum indices we are working with.
.
Now we can access each element of our container (Locals.Enum.FirstElement) and retrieve the corresponding enum index.
11-23-2008 10:29 PM
This way I can use the enumerated data type but how can I get the return value of the fiunction returning Enums. I tried to pass integer for storing the return value of the function but it gives error. Which data type can be used to store returned enum types?
Please reply urgently.
11-26-2008 02:54 AM
hi,
like in the post above you have to refer or call each element for the assignment, not the whole container. the error might be because of that...
hope tat solves ur issue.
vaibhav
12-03-2008 05:25 AM
I am using the C# dll having function which returns enumerated array? How can I handle that in Teststand?
In case of returning single enum I can get value using either string or integer but in case of enum array both string array and integer array didn't work. I am getting error in both cases?
Please reply urgently.
Thanks,
Saurabh
09-07-2012 02:31 PM
I know this is an old issue, but I am giving this response in case some one get to this thread.
Using the Container as proposed by John.B, you can use the TestStand PropertyObject to get the Nth Property Name.
09-10-2012 09:19 AM
@goel wrote:
I am using the C# dll having function which returns enumerated array? How can I handle that in Teststand?
In case of returning single enum I can get value using either string or integer but in case of enum array both string array and integer array didn't work. I am getting error in both cases?
Please reply urgently.
Thanks,
Saurabh
What version of TestStand are you using? There were major improvements made to the .NET adapter in TestStand 2010. I verified that an array of string and an array of numbers both work fine in recent versions of TestStand. If you are using the .NET adapter a lot? If so I highly recommend you upgrade to TestStand 2010 or higher (2012 was just released recently).
-Doug
09-10-2012 09:35 AM
I just realized I replied to a very old post, but oh well, hopefully that info will be useful to someone.
-Doug