public static void GetBuild( TLSCmdletBase cmdlet, TestPlan[] testPlans, string[] buildNames) { string testPlanNameNow = string.Empty; WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; try { foreach (TestPlan testPlan in testPlans) { testPlanNameNow = testPlan.name; System.Collections.Generic.List <Build> buildsList = TLAddinData.CurrentTestLinkConnection.GetBuildsForTestPlan(testPlan.id); if (null == buildNames || 0 == buildNames.Length) { cmdlet.WriteObject( cmdlet, buildsList); } else { foreach (Build build in buildsList) { foreach (string buildName in buildNames) { if ((new WildcardPattern(buildName, options)).IsMatch(build.name)) { cmdlet.WriteObject( cmdlet, build); } } } } } } catch (Exception eGetBuild) { cmdlet.WriteError( cmdlet, "Couldn't get builds from '" + testPlanNameNow + "'. " + eGetBuild.Message, "" + "CouldNotGetBuild", ErrorCategory.InvalidResult, true); } }
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); } }
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); } }
public static void GetProjectById(TLSCmdletBase cmdlet, string[] projectIds) { cmdlet.WriteObject( cmdlet, GetProjectsById( cmdlet, projectIds)); }
public static void GetProjectByName(TLSCmdletBase cmdlet, string[] projectNames) { cmdlet.WriteObject( cmdlet, GetProjectsByName( cmdlet, projectNames)); }
// public static void GetTestCaseFromTestPlan(TLSCmdletBase cmdlet, TestPlan[] testPlans, string[] testCaseNames) { foreach (TestPlan testPlan in testPlans) { System.Collections.Generic.List <TestCaseFromTestPlan> testCases = TLAddinData.CurrentTestLinkConnection.GetTestCasesForTestPlan(testPlan.id); if (null != testCaseNames && 0 < testCaseNames.Length) { foreach (TestCaseFromTestPlan testCase in testCases) { cmdlet.WriteObject(cmdlet, testCase); } } else { cmdlet.WriteObject(cmdlet, testCases); } } }
public static void GetTestPlans(TLSCmdletBase cmdlet, TestProject[] testProjects) { try { for (int i = 0; i < testProjects.Length; i++) { if (null == testProjects[i]) { if (null != TLAddinData.CurrentTestProject) { testProjects[i] = TLAddinData.CurrentTestProject; } else { cmdlet.WriteError( cmdlet, "You must specify a test project.", "NoTestProjectSpecified", ErrorCategory.InvalidArgument, true); } } System.Collections.Generic.List <TestPlan> listTestPlans = TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans( testProjects[i].id); foreach (TestPlan tplan in listTestPlans) { TLAddinData.CurrentTestPlan = tplan; } cmdlet.WriteObject(cmdlet, listTestPlans); } } catch (Exception eGetTestPlans) { cmdlet.WriteError( cmdlet, "Couldn't get test plans. " + eGetTestPlans.Message, "" + "CouldNotCreateTestPlan", ErrorCategory.InvalidResult, true); } }
public static void NewTestPlan( TLSCmdletBase cmdlet, string testPlanName, string testPlanNotes, bool active) { try { string description = string.Empty; if (null != testPlanNotes && string.Empty != testPlanNotes) { description = testPlanNotes; } GeneralResult result = TLAddinData.CurrentTestLinkConnection.CreateTestPlan( testPlanName, TLAddinData.CurrentTestProject.name, description, //activePlan); active); if (result.status) { TLAddinData.CurrentTestPlan = TLAddinData.CurrentTestLinkConnection.getTestPlanByName( TLAddinData.CurrentTestProject.name, testPlanName); } cmdlet.WriteObject(cmdlet, TLAddinData.CurrentTestPlan); } catch (Exception eNewTestPlan) { cmdlet.WriteError( cmdlet, "Couldn't create a test plan '" + testPlanName + "'. " + eNewTestPlan.Message, "" + "CouldNotCreateTestPlan", ErrorCategory.InvalidResult, true); } }
// public static void OpenTestCase(TLSCmdletBase cmdlet, string name) // { // throw new NotImplementedException(); // } public static void AddBuild( TLSCmdletBase cmdlet, TestPlan[] testPlans, string buildName, string buildNote) { try { for (int j = 0; j < testPlans.Length; j++) { string description = string.Empty; if (null != buildNote && string.Empty != buildNote) { description = buildNote; } GeneralResult result = TLAddinData.CurrentTestLinkConnection.CreateBuild( testPlans[j].id, buildName, description); if (result.status) { cmdlet.WriteObject( cmdlet, TLAddinData.CurrentTestLinkConnection.GetLatestBuildForTestPlan(testPlans[j].id)); } } } catch (Exception eAddBuild) { cmdlet.WriteError( cmdlet, "Couldn't create a build '" + buildName + "'. " + eAddBuild.Message, "" + "CouldNotCreateBuild", ErrorCategory.InvalidResult, true); } }
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); } }
// public static void GetTestCaseFromTestPlan(TLSCmdletBase cmdlet, Meyn.TestLink.TestPlan[] testPlans, string[] testCaseNames) { foreach (Meyn.TestLink.TestPlan testPlan in testPlans) { System.Collections.Generic.List<Meyn.TestLink.TestCaseFromTestPlan> testCases = TLAddinData.CurrentTestLinkConnection.GetTestCasesForTestPlan(testPlan.id); if (null != testCaseNames && 0 < testCaseNames.Length) { foreach (Meyn.TestLink.TestCaseFromTestPlan testCase in testCases) { cmdlet.WriteObject(cmdlet, testCase); } } else { cmdlet.WriteObject(cmdlet, testCases); } } }
public static void GetTestPlans(TLSCmdletBase cmdlet, Meyn.TestLink.TestProject[] testProjects) { try { for (int i = 0; i < testProjects.Length; i++) { if (null == testProjects[i]) { if (null != TLAddinData.CurrentTestProject) { testProjects[i] = TLAddinData.CurrentTestProject; } else { cmdlet.WriteError( cmdlet, "You must specify a test project.", "NoTestProjectSpecified", ErrorCategory.InvalidArgument, true); } } System.Collections.Generic.List<TestPlan> listTestPlans = TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans( testProjects[i].id); foreach (TestPlan tplan in listTestPlans) { TLAddinData.CurrentTestPlan = tplan; } cmdlet.WriteObject(cmdlet, listTestPlans); } } catch (Exception eGetTestPlans) { cmdlet.WriteError( cmdlet, "Couldn't get test plans. " + eGetTestPlans.Message, "" + "CouldNotCreateTestPlan", ErrorCategory.InvalidResult, true); } }
public static void GetProjectById(TLSCmdletBase cmdlet, string[] projectIds) { cmdlet.WriteObject( cmdlet, TLHelper.GetProjectsById( cmdlet, projectIds)); }
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); } }
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); }
public static void GetTestCaseFromTestSuite(TLSCmdletBase cmdlet, TestSuite[] testSuites, string[] testCaseNames, bool deep) { foreach (TestSuite testSuite in testSuites) { System.Collections.Generic.List<TestCaseFromTestSuite> testCases = TLAddinData.CurrentTestLinkConnection.GetTestCasesForTestSuite(testSuite.id, deep); if (null != testCaseNames && 0 < testCaseNames.Length) { foreach (TestCaseFromTestSuite testCase in testCases) { cmdlet.WriteObject(cmdlet, testCase); } } else { cmdlet.WriteObject(cmdlet, testCases); } } }
public static void GetBuild( TLSCmdletBase cmdlet, TestPlan[] testPlans, string[] buildNames) { string testPlanNameNow = string.Empty; WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled; try { foreach (Meyn.TestLink.TestPlan testPlan in testPlans) { testPlanNameNow = testPlan.name; System.Collections.Generic.List<Meyn.TestLink.Build> buildsList = TLAddinData.CurrentTestLinkConnection.GetBuildsForTestPlan(testPlan.id); if (null == buildNames || 0 == buildNames.Length) { cmdlet.WriteObject( cmdlet, buildsList); } else { foreach (Meyn.TestLink.Build build in buildsList) { foreach (string buildName in buildNames) { if ((new WildcardPattern(buildName, options)).IsMatch(build.name)) { cmdlet.WriteObject( cmdlet, build); } } } } } } catch (Exception eGetBuild) { cmdlet.WriteError( cmdlet, "Couldn't get builds from '" + testPlanNameNow + "'. " + eGetBuild.Message, "" + "CouldNotGetBuild", ErrorCategory.InvalidResult, true); } }
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); }