New test set

Public Function GetTestSet(testSetF As TestSetFolder, _
        tsName As String, _
        tsStatus As String) As TestSet
' New test set

' Find the test set in the folder and return it.
' If it does not exist, create it.

    Dim testSetFolderF As TestSetTreeManager
    'Dim testSetF As TestSet
    Dim testSet1 As TestSet, ts As TestSet
    Dim tsList As List
    Dim found As Boolean
    
    On Error GoTo FUNC_ERR
    'Set testSetFolderF = tdc.TestSetTreeManager
    'Set tstSetFolder = testSetFolderF.NodeByPath("Root\TestSetFolder3")
    'Set testSetF = tstSetFolder.TestSetFactory
    Set tsList = testSetF.FindTestSets(tsName)
    If Not (tsList Is Nothing) Then
        If tsList.Count > 0 Then
           
            For Each ts In tsList
                If ts.Name = tsName Then
                    Set testSet1 = ts
                    found = True
                    Exit For
                End If
            Next ts
        End If
    End If
    
    If Not found Then
        Dim tsFact As TestSetFactory
        Set tsFact = testSetF.TestSetFactory
        
        Set testSet1 = tsFact.AddItem(Null)
        testSet1.Name = tsName
        'testSet1.Status = "Open"
        testSet1.Status = tsStatus
'        testSet1.Field("CY_CYCLE") = tsName
        testSet1.Post
    End If
    Set GetTestSet = testSet1
Exit Function
FUNC_ERR:
    Set GetTestSet = Nothing
End Function