Forum Discussion

jhgreen's avatar
jhgreen
Contributor
12 years ago

Calling dll function which returns list


I am calling a dll function which returns a list of strings, I cannot figure out how to access the values of the list.

When I cycle through the listreturned it just gives me a value of undefined.



Here is my DLL function call



using System;

using System.Collections.Generic;

using System.Collections.Specialized;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.VersionControl.Client;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

using Microsoft.TeamFoundation.TestManagement.Client;



namespace TestComplete

{

    public class UnitTests

    {

        public List<string> GetUnitTests(String server, String project)

        {

            /// <summary>

            /// Gets all the unit tests for a specific project.

            /// </summary>

            /// <param name="server" type="String">

            /// Server name

            /// </param>

            /// <param name="project" type="String">

            /// Project name

            /// </param>

            ///



            TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(server));

            WorkItemStore wiStore = tfs.GetService<WorkItemStore>();

            Project teamProject = wiStore.Projects[project];

            string selectQuery = "SELECT * FROM WorkItems WHERE [System.TeamProject] = '" + project + "' AND [Work Item Type] = 'Test Case'";

            string workItemString = "";

            WorkItem lastWorkItem = null;

            List<string> workItemList = new List<string>();





            WorkItemCollection wiCollection = wiStore.Query(selectQuery);



            foreach (WorkItem wiItem in wiCollection)

            {

                workItemString += wiItem.Title;

                workItemList.Add(wiItem.Title);

                lastWorkItem = wiItem;

            }



            return workItemList;



        }

    }

}





Here is my test complete script



function get_unittests()

{

    var returnList;

    var title;

    var cntr;

    var listCount;

    var title;

    // Get local changeset version

    returnList = dotNET.TestComplete.UnitTests.zctor().GetUnitTests(Project.Variables.Server, Project.Variables.TFSProject);

    Log.Message("return list is " + returnList);

    Log.Message("count of return list is " + returnList.Count);

   

    for ( cntr = 0; cntr < listCount; cntr++)

    {

        title = returnList[cntr];

        Log.Message("title is " + title);

    }

  

   

}



Any help would be greatly appreciated.



Thanks,

Jeff


  • Found answer. If I use the following line it gives me the correct value




    Log.Message("value 1 is " + returnList.get_Item(1));