/// <summary> /// get a list of all projects /// </summary> /// <returns></returns> public List<TestProject> GetProjects() { stateIsValid(); object response = null; response = proxy.getProjects(devkey); List<TestProject> retval = new List<TestProject>(); if ((response is string) && ((string)response == string.Empty)) // equals null return return retval; object[] list = response as object[]; handleErrorMessage(list); foreach (XmlRpcStruct entry in list) { TestProject tp = new TestProject(entry); retval.Add(tp); } return retval; }
// no project specified and there's no project in the store private System.Collections.Generic.List<TestPlan> getTestPlansByProjectName( TestProject currentTestProject, string[] testProjectNames, System.Collections.Generic.List<TestPlan> testPlans, bool makeFail, bool projectNamesNotSpecified) { TLGetTestPlanCmdletBase cmdlet = new TLGetTestPlanCmdletBase(); if (projectNamesNotSpecified) { cmdlet.TestProjectName = null; } else { cmdlet.TestProjectName = testProjectNames; } //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0001"); System.Collections.Generic.List<Meyn.TestLink.TestProject> testProjects = new System.Collections.Generic.List<Meyn.TestLink.TestProject>(); testProjects.Add(TLAddinData.CurrentTestProject); //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0002"); TLAddinData.CurrentTestLinkConnection = FakeTestLinkFactory.GetTestLinkWithTestPlans(testProjects, testPlans, null, null); //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0003"); if (projectNamesNotSpecified) { //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0004_1"); TLAddinData.CurrentTestProject = currentTestProject; //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0004_2"); } if (makeFail) { //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0005_1"); TLAddinData.CurrentTestLinkConnection = null; //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0005_2"); } TLSrvGetTestPlanCommand command = new TLSrvGetTestPlanCommand(cmdlet); command.Execute(); //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0006"); System.Collections.Generic.List<TestPlan> resultList = new System.Collections.Generic.List<TestPlan>(); //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0007"); foreach (object tpl in PSTestLib.UnitTestOutput.LastOutput) { //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0008_1"); resultList.Add((TestPlan)tpl); //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0008_2"); } //cmdlet.WriteTrace(cmdlet, "getTestPlansByProjectName: 0009"); return resultList; }
/// <summary> /// get a single Project /// </summary> /// <param name="projectname"></param> /// <returns>a Project or Null</returns> public TestProject GetProject(string projectname) { TestProject result = null; stateIsValid(); object o = proxy.getTestProjectByName(devkey, projectname); handleErrorMessage(o); if (o is object[]) { object[] olist = o as object[]; result = new TestProject(olist[0] as XmlRpcStruct); } else result = new TestProject(o as XmlRpcStruct); return result; }
public static void GetTestSuiteFromProject(TLTestSuiteCmdletBase cmdlet, TestProject[] testProjects) { string testProjectNameNow = string.Empty; try { foreach (TestProject testProject in testProjects) { testProjectNameNow = testProject.name; cmdlet.WriteVerbose( cmdlet, "getting suites from the test project '" + testProjectNameNow + "'."); System.Collections.Generic.List<TestSuite> list = TLAddinData.CurrentTestLinkConnection.GetFirstLevelTestSuitesForTestProject(testProject.id); cmdlet.WriteVerbose(cmdlet, "There have been found " + list.Count.ToString() + " test suites."); foreach (TestSuite testSuiteFound in list) { TLAddinData.CurrentTestSuite = testSuiteFound; } cmdlet.WriteObject(cmdlet, list); } } catch (Exception eTestProject) { cmdlet.WriteError( cmdlet, "Failed to get suites from the project '" + testProjectNameNow + "'. " + eTestProject.Message, "FailedToGetSuites", ErrorCategory.InvalidResult, true); } }
/// <summary> /// get the specific project and associated plans for this TestLinkFixture /// </summary> /// <param name="tlfa"></param> /// <returns>a valid testplanID or 0 if testplan or project was not found</returns> private int GetProjectAndPlans(TestLinkFixtureAttribute tlfa) { // make sure proxy is right SetupProxy(tlfa); int testPlanId = 0; if ((currentProject == null) || (currentProject.name != tlfa.ProjectName)) { currentProject = null; plans = null; foreach (TestProject project in allProjects) if (project.name == tlfa.ProjectName) { currentProject = project; plans = proxy.GetProjectTestPlans(project.id); break; } if (currentProject == null) { return 0; } } // now that currentProject and plans are up to date foreach (TestPlan plan in plans) if (plan.name == tlfa.TestPlan) { testPlanId = plan.id; break; } return testPlanId; }
public static void GetTestCaseFromProject(TLSCmdletBase cmdlet, TestProject[] testProjects, string[] testCaseNames) { foreach (TestProject project in testProjects) { System.Collections.Generic.List<TestPlan> testPlans = TLAddinData.CurrentTestLinkConnection.GetProjectTestPlans(project.id); GetTestCaseFromTestPlan(cmdlet, testPlans.ToArray(), testCaseNames); System.Collections.Generic.List<TestSuite> firstLevelTestSuites = TLAddinData.CurrentTestLinkConnection.GetFirstLevelTestSuitesForTestProject(project.id); GetTestCaseFromTestSuite(cmdlet, firstLevelTestSuites.ToArray(), testCaseNames, true); // foreach (Meyn.TestLink.TestSuite suite in firstLevelTestSuites) { // // // } } }
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 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); } }
/// <summary> /// update selected bits of the testlink fixture data /// </summary> /// <param name="newProject"></param> /// <param name="newTestPlan"></param> /// <param name="newTestSuite"></param> /// <returns>true if data have been set up successfully</returns> private bool updateData(bool newProject, bool newTestPlan, bool newTestSuite) { if (basicConnectionValid == false) { testProjectId = 0; testPlanId = 0; testSuiteId = 0; return(false); } if (newProject) { testProjectId = 0; AllTestPlans = new List <TestPlan>(); foreach (TestProject project in allProjects) { if (project.name == connectionData.ProjectName) { currentProject = project; testProjectId = project.id; AllTestPlans = proxy.GetProjectTestPlans(project.id); break; } } if (testProjectId == 0) { testPlanId = 0; testSuiteId = 0; Console.WriteLine("Test Project '{0}' was not found in TestLink", connectionData.ProjectName); return(false); } } else if (testProjectId == 0) // it was wrong and hasn't changed { return(false); } if (newTestPlan) { testPlanId = 0; foreach (TestPlan tp in AllTestPlans) { if (tp.name == connectionData.TestPlan) { testPlanId = tp.id; break; } } if (testPlanId == 0) { testSuiteId = 0; Console.WriteLine("Test plan '{0}' was not found in project '{1}'", connectionData.TestPlan, connectionData.ProjectName); return(false); } } else if (testPlanId == 0) // it was wrong and hasn't changed { return(false); } if (newTestSuite) { testSuiteId = GetTestSuiteId(testProjectId, connectionData.TestSuite); if (testSuiteId == 0) { Console.WriteLine("Test suite '{0}' was not found in project '{1}'", connectionData.TestSuite, connectionData.ProjectName); return(false); } } else if (testSuiteId == 0) // it was wrong and hasn't changed { return(false); } return(true); }
/// <summary> /// update selected bits of the testlink fixture data /// </summary> /// <param name="newProject"></param> /// <param name="newTestPlan"></param> /// <param name="newTestSuite"></param> /// <returns>true if data have been set up successfully</returns> private bool updateData(bool newProject, bool newTestPlan, bool newTestSuite) { if (basicConnectionValid == false) { testProjectId = 0; testPlanId = 0; testSuiteId = 0; return false; } if (newProject) { testProjectId = 0; AllTestPlans = new List<TestPlan>(); foreach (TestProject project in allProjects) if (project.name == connectionData.ProjectName) { currentProject = project; testProjectId = project.id; AllTestPlans = proxy.GetProjectTestPlans(project.id); break; } if (testProjectId == 0) { testPlanId = 0; testSuiteId = 0; Console.WriteLine("Test Project '{0}' was not found in TestLink", connectionData.ProjectName); return false; } } else if (testProjectId == 0) // it was wrong and hasn't changed return false; if (newTestPlan) { testPlanId = 0; foreach (TestPlan tp in AllTestPlans) if (tp.name == connectionData.TestPlan) { testPlanId = tp.id; break; } if (testPlanId == 0) { testSuiteId = 0; Console.WriteLine("Test plan '{0}' was not found in project '{1}'", connectionData.TestPlan, connectionData.ProjectName); return false; } } else if (testPlanId == 0) // it was wrong and hasn't changed return false; if (newTestSuite) { testSuiteId = GetTestSuiteId(testProjectId, connectionData.TestSuite); if (testSuiteId == 0) { Console.WriteLine("Test suite '{0}' was not found in project '{1}'", connectionData.TestSuite, connectionData.ProjectName); return false; } } else if (testSuiteId == 0) // it was wrong and hasn't changed return false; return true; }