Meyn.TestLink.TestLink.GetProjectTestPlans C# (CSharp) Method

GetProjectTestPlans() public method

get a list of all testplans for a project
public GetProjectTestPlans ( int projectid ) : List
projectid int
return List
        public List<TestPlan> GetProjectTestPlans(int projectid)
        {
            List<TestPlan> retval = new List<TestPlan>();
            object response = null;
            stateIsValid();
            // Checked Testlink V 1.9.2 Still behaves this way
            try {
                response = proxy.getProjectTestPlans(devkey, projectid);
            // if a project has no test plans this exception is thrown
            } catch (XmlRpcTypeMismatchException) {
                return retval;
                // empty list
            // happens when no plans exist. Empty response is sent back
            } catch (InvalidCastException) {
                return retval;
                // empty list
            }

            handleErrorMessage(response);
            if ((response is string) && ((string)response == string.Empty))
                // equals null return
                return retval;
            XmlRpcStruct[] results = response as XmlRpcStruct[];
            object[] oList = response as object[];
            if ((oList.Length == 0) || (oList[0] is string))
                return retval;

            foreach (XmlRpcStruct result in oList) {
                TestPlan tp = new TestPlan(result);
                retval.Add(tp);
            }
            return retval;
        }
        /// <summary>

Usage Example

Example #1
0
        /// <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);
        }