示例#1
0
        public static void GetProjectCollection(TLSCmdletBase cmdlet)
        {
            try {
                cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: getting list of projects");
                System.Collections.Generic.List <TestProject> listProjects =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: outputting projects");
                cmdlet.WriteObject(cmdlet, listProjects);

                // 20130131
                if (null != listProjects && 0 < listProjects.Count)
                {
                    cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: settiing the current test project");
                    TLAddinData.CurrentTestProject =
                        listProjects[listProjects.Count - 1];
                }
            }
            catch (Exception eProjectCollection) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the list of projects. " +
                    eProjectCollection.Message,
                    "UnableToGetProjects",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
示例#2
0
        public static void GetTestPlan(TLSCmdletBase cmdlet, TestProject[] testProjects, string[] testPlanNames)
        {
            string testPlanNameNow = string.Empty;

            try {
//                if (null == testProjects || 0 == testProjects.Length) {
//                    if (null != TLAddinData.CurrentTestProject) {
//                        testProjects = new Meyn.TestLink.TestProject[1];
//                        testProjects[0] = TLAddinData.CurrentTestProject;
//                    }
//                }

                if (null == testProjects || 0 == testProjects.Length)
                {
                    //cmdlet.WriteObject(cmdlet, null); // ??
                    return;
                }

                foreach (TestProject testProject in testProjects)
                {
                    foreach (string name in testPlanNames)
                    {
                        testPlanNameNow = name;

                        cmdlet.WriteVerbose(
                            cmdlet,
                            "Trying to get test plan '" +
                            testPlanNameNow +
                            "' from the project '" +
                            testProject.name +
                            "'.");

                        TestPlan testPlan =
                            TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                                testProject.name,
                                testPlanNameNow);

                        if (null != testPlan)
                        {
                            TLAddinData.CurrentTestPlan = testPlan;

                            cmdlet.WriteObject(cmdlet, testPlan);
                        }
                    }
                }
            }
            catch (Exception eGetTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plan '" +
                    testPlanNameNow +
                    "'. " +
                    eGetTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
示例#3
0
        internal static TestProject[] GetProjectsById(TLSCmdletBase cmdlet, string[] projectIds)
        {
            System.Collections.Generic.List <TestProject> resultList =
                new System.Collections.Generic.List <TestProject>();

            string projectIdNow = string.Empty;

            try {
                cmdlet.WriteVerbose(cmdlet, "collecting all projects");
                System.Collections.Generic.List <TestProject> projectsList =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "iterating through the project colection");
                foreach (TestProject testProject in projectsList)
                {
                    cmdlet.WriteVerbose(cmdlet, "iterating through the project ids colection");
                    foreach (string id in projectIds)
                    {
                        if (Convert.ToInt32(id) == testProject.id)
                        {
                            TLAddinData.CurrentTestProject = testProject;
                            cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");

                            resultList.Add(testProject);
                        }
                    }
                }
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project by id. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            TestProject[] resultArray =
                resultList.ToArray();

            return(resultArray);
        }
示例#4
0
        internal static TestProject[] GetProjectsByName(TLSCmdletBase cmdlet, string[] projectNames)
        {
            System.Collections.Generic.List <TestProject> resultList =
                new System.Collections.Generic.List <TestProject>();

            string projectNameNow = string.Empty;

            try {
                cmdlet.WriteVerbose(cmdlet, "iterating through the project names collection");
                foreach (string name in projectNames)
                {
                    cmdlet.WriteVerbose(cmdlet, name);
                    projectNameNow = name;

                    cmdlet.WriteVerbose(cmdlet, "getting project '" + projectNameNow + "'.");
                    TestProject testProject =
                        TLAddinData.CurrentTestLinkConnection.GetProject(projectNameNow);

                    if (null != testProject)
                    {
                        TLAddinData.CurrentTestProject = testProject;
                        cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");
                    }
                    resultList.Add(TLAddinData.CurrentTestProject);
                }
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project '" +
                    projectNameNow +
                    "'. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            TestProject[] resultArray =
                resultList.ToArray();

            return(resultArray);
        }
示例#5
0
 public static void GetTestSuite(TLSCmdletBase cmdlet, string[] suiteNames)
 {
     System.Collections.Generic.List<string> testSuiteNames =
         new System.Collections.Generic.List<string>();
     foreach (string suiteName in suiteNames) {
         testSuiteNames.Add(suiteName);
     }
     
     System.Collections.Generic.List<Meyn.TestLink.TestSuite> testSuites =
         new System.Collections.Generic.List<Meyn.TestLink.TestSuite>();
     
     // getting test projects
     System.Collections.Generic.List<TestProject> testProjects =
         TLAddinData.CurrentTestLinkConnection.GetProjects();
     
     // getting first level test suites
     if (null != testProjects && 0 < testProjects.Count) {
         
         cmdlet.WriteVerbose(
             cmdlet,
             "Found " +
             testProjects.Count.ToString() +
             " projects.");
         
         foreach (TestProject testProject in testProjects) {
             
             cmdlet.WriteVerbose(
                 cmdlet,
                 "getting first level test suites from the project '" +
                 testProject.name +
                 ",.");
             System.Collections.Generic.List<Meyn.TestLink.TestSuite> firstLevelTestSuites =
                 TLAddinData.CurrentTestLinkConnection.GetFirstLevelTestSuitesForTestProject(testProject.id);
             
             if (null != firstLevelTestSuites && 0 < firstLevelTestSuites.Count) {
                 
                 cmdlet.WriteVerbose(
                     cmdlet,
                     "There are " +
                     firstLevelTestSuites.Count.ToString() +
                     " first-level test suites in the project '" +
                     testProject.name +
                     "'.");
                 
                 foreach (string  testSuiteName in testSuiteNames) {
                     System.Collections.Generic.List<Meyn.TestLink.TestSuite> suitesThatMatch =
                         firstLevelTestSuites.FindAll(s => s.name == testSuiteName);
                     if (null != suitesThatMatch && 0 < suitesThatMatch.Count) {
                         
                         cmdlet.WriteVerbose(
                             cmdlet,
                             "There are " +
                             suitesThatMatch.Count.ToString() +
                             " first-level test suites that match names.");
                         
                         testSuites.AddRange(suitesThatMatch);
                     }
                 }
                 
                 // getting down-level test suites
                 foreach (Meyn.TestLink.TestSuite firstLevelTestSuite in firstLevelTestSuites) {
                     
                     cmdlet.WriteVerbose(
                         cmdlet,
                         "getting down-level test suites from the test suite '" +
                         firstLevelTestSuite.name +
                         "'.");
                     
                     System.Collections.Generic.List<Meyn.TestLink.TestSuite> downLevelTestSuites =
                         TLAddinData.CurrentTestLinkConnection.GetTestSuitesForTestSuite(firstLevelTestSuite.id);
                     
                     if (null != downLevelTestSuites && 0 < downLevelTestSuites.Count) {
                         
                         cmdlet.WriteVerbose(
                             cmdlet,
                             "There are " +
                             downLevelTestSuites.Count.ToString() + 
                             " down-level test suites in the first-level test suite '" +
                             firstLevelTestSuite.name +
                             "'.");
                         
                         foreach (string testSuiteName in testSuiteNames) {
                             System.Collections.Generic.List<Meyn.TestLink.TestSuite> dlSuitesThatMatch =
                                 downLevelTestSuites.FindAll(d => d.name == testSuiteName);
                             if (null != dlSuitesThatMatch && 0 < dlSuitesThatMatch.Count) {
                                 
                                 cmdlet.WriteVerbose(
                                     cmdlet,
                                     "There are " +
                                     dlSuitesThatMatch.Count.ToString() +
                                     " down-level test suites that match names.");
                                 
                                 testSuites.AddRange(dlSuitesThatMatch);
                             }
                         }
                         
                     }
                     
                 }
                 
             }
             
         }
         
     }
     
     
     // outputting the test suites collections
     cmdlet.WriteObject(cmdlet, testSuites);
 }
示例#6
0
        public static void GetTestPlan(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects, string[] testPlanNames)
        {
            string testPlanNameNow = string.Empty;
            
            try {
                
//                if (null == testProjects || 0 == testProjects.Length) {
//                    if (null != TLAddinData.CurrentTestProject) {
//                        testProjects = new Meyn.TestLink.TestProject[1];
//                        testProjects[0] = TLAddinData.CurrentTestProject;
//                    }
//                }
                
                if (null == testProjects || 0 == testProjects.Length) {
                    //cmdlet.WriteObject(cmdlet, null); // ??
                    return;
                }
                
                foreach (Meyn.TestLink.TestProject testProject in testProjects) {
                    foreach (string name in testPlanNames) {
                        
                        testPlanNameNow = name;
                    
                        cmdlet.WriteVerbose(
                            cmdlet, 
                            "Trying to get test plan '" +
                            testPlanNameNow +
                            "' from the project '" + 
                            testProject.name +
                            "'.");
                        
                        TestPlan testPlan =
                            TLAddinData.CurrentTestLinkConnection.getTestPlanByName(
                                testProject.name,
                                testPlanNameNow);
                        
                        if (null != testPlan) {
                        
                            TLAddinData.CurrentTestPlan = testPlan;
        
                            cmdlet.WriteObject(cmdlet, testPlan);
                        }
                    
                    }
                }
            }
            catch (Exception eGetTestPlan) {
                cmdlet.WriteError(
                    cmdlet,
                    "Couldn't get test plan '" +
                    testPlanNameNow +
                    "'. " +
                    eGetTestPlan.Message,
                    "" +
                    "CouldNotCreateTestPlan",
                    ErrorCategory.InvalidResult,
                    true);
            }
        }
示例#7
0
        internal static Meyn.TestLink.TestProject[] GetProjectsById(TLSCmdletBase cmdlet, string[] projectIds)
        {
            System.Collections.Generic.List<Meyn.TestLink.TestProject> resultList =
                new System.Collections.Generic.List<Meyn.TestLink.TestProject>();

            string projectIdNow = string.Empty;
            
            try {

                cmdlet.WriteVerbose(cmdlet, "collecting all projects");
                System.Collections.Generic.List<Meyn.TestLink.TestProject> projectsList =
                    TLAddinData.CurrentTestLinkConnection.GetProjects();

                cmdlet.WriteVerbose(cmdlet, "iterating through the project colection");
                foreach (Meyn.TestLink.TestProject testProject in projectsList) {

                    cmdlet.WriteVerbose(cmdlet, "iterating through the project ids colection");
                    foreach (string id in projectIds) {

                        if (Convert.ToInt32(id) == testProject.id) {

                            TLAddinData.CurrentTestProject = testProject;
                            cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");

                            resultList.Add(testProject);
                        }
                    }
                }
                
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project by id. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            Meyn.TestLink.TestProject[] resultArray =
                resultList.ToArray();

            return resultArray;
        }
示例#8
0
        internal static Meyn.TestLink.TestProject[] GetProjectsByName(TLSCmdletBase cmdlet, string[] projectNames)
        {
            System.Collections.Generic.List<Meyn.TestLink.TestProject> resultList =
                new System.Collections.Generic.List<Meyn.TestLink.TestProject>();
            
            string projectNameNow = string.Empty;
            
            try {
                
                cmdlet.WriteVerbose(cmdlet, "iterating through the project names collection");
                foreach (string name in projectNames) {
                    
                    cmdlet.WriteVerbose(cmdlet, name);
                    projectNameNow = name;
                    
                    cmdlet.WriteVerbose(cmdlet, "getting project '" + projectNameNow + "'.");
                    TestProject testProject =
                        TLAddinData.CurrentTestLinkConnection.GetProject(projectNameNow);
                    
                    if (null != testProject) {
                        TLAddinData.CurrentTestProject = testProject;
                        cmdlet.WriteVerbose(cmdlet, "got the project '" + testProject.name + "'.");
                    }
                    resultList.Add(TLAddinData.CurrentTestProject);
                }
                
            }
            catch (Exception eProject) {
                cmdlet.WriteError(
                    cmdlet,
                    "Unable to get the project '" +
                    projectNameNow +
                    "'. " +
                    eProject.Message,
                    "UnableToGetProject",
                    ErrorCategory.InvalidResult,
                    true);
            }

            Meyn.TestLink.TestProject[] resultArray =
                resultList.ToArray();

            return resultArray;
        }
示例#9
0
 public static void GetProjectCollection(TLSCmdletBase cmdlet)
 {
     try {
         
         cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: getting list of projects");
         System.Collections.Generic.List<TestProject> listProjects =
             TLAddinData.CurrentTestLinkConnection.GetProjects();
         
         cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: outputting projects");
         cmdlet.WriteObject(cmdlet, listProjects);
         
         // 20130131
         if (null != listProjects && 0 < listProjects.Count) {
             cmdlet.WriteVerbose(cmdlet, "GetProjectCollection: settiing the current test project");
             TLAddinData.CurrentTestProject =
                 listProjects[listProjects.Count -1];
         }
     }
     catch (Exception eProjectCollection) {
         cmdlet.WriteError(
             cmdlet,
             "Unable to get the list of projects. " +
             eProjectCollection.Message,
             "UnableToGetProjects",
             ErrorCategory.InvalidResult,
             true);
     }
 }
示例#10
0
        public static void GetTestSuite(TLSCmdletBase cmdlet, string[] suiteNames)
        {
            System.Collections.Generic.List <string> testSuiteNames =
                new System.Collections.Generic.List <string>();
            foreach (string suiteName in suiteNames)
            {
                testSuiteNames.Add(suiteName);
            }

            System.Collections.Generic.List <TestSuite> testSuites =
                new System.Collections.Generic.List <TestSuite>();

            // getting test projects
            System.Collections.Generic.List <TestProject> testProjects =
                TLAddinData.CurrentTestLinkConnection.GetProjects();

            // getting first level test suites
            if (null != testProjects && 0 < testProjects.Count)
            {
                cmdlet.WriteVerbose(
                    cmdlet,
                    "Found " +
                    testProjects.Count.ToString() +
                    " projects.");

                foreach (TestProject testProject in testProjects)
                {
                    cmdlet.WriteVerbose(
                        cmdlet,
                        "getting first level test suites from the project '" +
                        testProject.name +
                        ",.");
                    System.Collections.Generic.List <TestSuite> firstLevelTestSuites =
                        TLAddinData.CurrentTestLinkConnection.GetFirstLevelTestSuitesForTestProject(testProject.id);

                    if (null != firstLevelTestSuites && 0 < firstLevelTestSuites.Count)
                    {
                        cmdlet.WriteVerbose(
                            cmdlet,
                            "There are " +
                            firstLevelTestSuites.Count.ToString() +
                            " first-level test suites in the project '" +
                            testProject.name +
                            "'.");

                        foreach (string testSuiteName in testSuiteNames)
                        {
                            System.Collections.Generic.List <TestSuite> suitesThatMatch =
                                firstLevelTestSuites.FindAll(s => s.name == testSuiteName);
                            if (null != suitesThatMatch && 0 < suitesThatMatch.Count)
                            {
                                cmdlet.WriteVerbose(
                                    cmdlet,
                                    "There are " +
                                    suitesThatMatch.Count.ToString() +
                                    " first-level test suites that match names.");

                                testSuites.AddRange(suitesThatMatch);
                            }
                        }

                        // getting down-level test suites
                        foreach (TestSuite firstLevelTestSuite in firstLevelTestSuites)
                        {
                            cmdlet.WriteVerbose(
                                cmdlet,
                                "getting down-level test suites from the test suite '" +
                                firstLevelTestSuite.name +
                                "'.");

                            System.Collections.Generic.List <TestSuite> downLevelTestSuites =
                                TLAddinData.CurrentTestLinkConnection.GetTestSuitesForTestSuite(firstLevelTestSuite.id);

                            if (null != downLevelTestSuites && 0 < downLevelTestSuites.Count)
                            {
                                cmdlet.WriteVerbose(
                                    cmdlet,
                                    "There are " +
                                    downLevelTestSuites.Count.ToString() +
                                    " down-level test suites in the first-level test suite '" +
                                    firstLevelTestSuite.name +
                                    "'.");

                                foreach (string testSuiteName in testSuiteNames)
                                {
                                    System.Collections.Generic.List <TestSuite> dlSuitesThatMatch =
                                        downLevelTestSuites.FindAll(d => d.name == testSuiteName);
                                    if (null != dlSuitesThatMatch && 0 < dlSuitesThatMatch.Count)
                                    {
                                        cmdlet.WriteVerbose(
                                            cmdlet,
                                            "There are " +
                                            dlSuitesThatMatch.Count.ToString() +
                                            " down-level test suites that match names.");

                                        testSuites.AddRange(dlSuitesThatMatch);
                                    }
                                }
                            }
                        }
                    }
                }
            }


            // outputting the test suites collections
            cmdlet.WriteObject(cmdlet, testSuites);
        }