Get attributes of TestSets and Test instances

Public Sub TSTestProperties(theTestSet As TestSet)

' Get attributes of TestSets and TSTests
    
    Dim i%

' Get the test set attributes.
    With theTestSet
        Debug.Print "Test Set ID = " & .ID & ", Name = " _
            & .Name & ",  TestSetFolder = " & .TestSetFolder
'Output:
'Test Set ID = 14, Name = OTA_TS_2, TestSetFolder = OTA_Demo_TestSets
    End With ' theTestSet
    
' Get the TSTest factory and list of TSTests.
    Dim TSTestFact as TSTestFactory
    Dim TestSetTestsList as List
    
    Set TSTestFact = theTestSet.TSTestFactory
    Set TestSetTestsList = TSTestFact.NewList("")
    
    Dim sID$, theTSTest As TSTest
    For Each theTSTest In TestSetTestsList
        i = i + 1: If i > 10 Then Exit For
        With theTSTest
            Debug.Print "TSTest Name: " & .Name, "ID: " & .ID, _
                "TestID: " & .testID, "Instance: " & .instance
            sID = theTSTest.ID 'Save the last ID
        End With
    Next theTSTest
'Output:
'TSTest Name: [1]TEST1.1.1.1_A ID: 95~1 TestID: 95 Instance: 1
'TSTest Name: [1]TEST1.1.1.1_B ID: 96~1 TestID: 96 Instance: 1
'TSTest Name: [2]TEST1.1.1.1_A ID: 95~2 TestID: 95 Instance: 2
'TSTest Name: [2]TEST1.1.1.1_B ID: 96~2 TestID: 96 Instance: 2
'TSTest Name: [3]TEST1.1.1.1_A ID: 95~3 TestID: 95 Instance: 3

    Debug.Print "Last TSTestID = " & sID
'Output:
'Last TSTestID = 95~3

' Set a specific TSTest by the ID.
    Set theTSTest = TSTestFact.Item(sID)
    With theTSTest
    Debug.Print "TSTest by ID Name: " & .Name, "ID: " & .ID, _
        "TestID: " & .testID, "Instance: " & .instance
    End With
'Output:
'TSTest by ID Name: [3]TEST1.1.1.1_A ID: 95~3 TestID: 95 Instance: 3

Exit Sub


' #Region "TestSetLinks"
Public Sub TestSetLinks()

' Get a list of links from a Test Set

    Dim TSetFact As TestSetFactory
    Dim tsFact As TSTestFactory
    Dim aTestSet As TestSet
    Dim tsSets As List, Links As List
    
' Get the list of test sets from the test set factory.
    'tdc is the global TDConnection object.
    Set TSetFact = tdc.TestSetFactory
    Set tsSets = TSetFact.NewList("")
' Get any test set (for demonstration purposes).
    Set aTestSet = tsSets.Item(1)
    Debug.Print aTestSet.ID, aTestSet.Name
' To get the BugLinkFactory,
' cast the test set variable to an ILinkable
' reference. Note that implemented interfaces are
' not directly accessible, so this won't work:
'   Set LinkF = TestSet.BugLinkFactory
'
    Dim linkableTestSet As ILinkable
' The cast:
    Set linkableTestSet = aTestSet
' Get the factory from the iLinkable reference.
    Dim linkF As LinkFactory
    Set linkF = linkableTestSet.BugLinkFactory
' Now use the factory.
'
'-------------------------------------
' Application code.
    Set Links = linkF.NewList("")
    Debug.Print Links.Count
    ' etc.
'-------------------------------------
End Sub