Esempio n. 1
0
        /// <inheritdoc />
        public IDictionary <string, string> GetConfigurationVariables(TfsTestRunProperties runProperties)
        {
            if (runProperties == null)
            {
                throw new ArgumentNullException("runProperties");
            }

            TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(runProperties.TfsServerCollectionUrl));

            teamProjectCollection.Credentials = this.credentials;

            TestManagementService testService = teamProjectCollection.GetService <TestManagementService>();

            ITestManagementTeamProject teamProject = testService.GetTeamProject(runProperties.TeamProject);

            if (teamProject == null)
            {
                throw new InvalidOperationException(String.Format("Failed to find team project named '{0}'", runProperties.TeamProject));
            }

            ITestConfiguration testConfiguration = teamProject.TestConfigurations.Find(runProperties.TestConfigurationId);

            if (testConfiguration == null)
            {
                throw new InvalidOperationException(String.Format("Failed to find test configuration with ID '{0}'. If you're running this tool in a test run managed by VSTS, you make need to upgrade your license for the user executing the test run.", runProperties.TestConfigurationId));
            }

            return(testConfiguration.Values);
        }
        protected void LoadTestPlansForProject()
        {
            //Create the list of plans
            List <string> testPlans = new List <string>();

            testPlans.Add(Utils.ALL_TEST_PLANS);

            //Get the current project name
            if (this.cboProject.SelectedValue != null)
            {
                string projectName = this.cboProject.SelectedValue.ToString();
                if (!String.IsNullOrWhiteSpace(projectName))
                {
                    //Get the list of plans for this project
                    TfsTeamProjectCollection   tfsTeamProjectCollection;
                    TestManagementService      testManagementService = GetMtmServiceInstance(out tfsTeamProjectCollection);
                    ITestManagementTeamProject mtmProject            = testManagementService.GetTeamProject(projectName);
                    if (mtmProject != null)
                    {
                        ITestPlanCollection plans = mtmProject.TestPlans.Query("Select * From TestPlan");
                        foreach (ITestPlan mtmTestPlan in plans)
                        {
                            testPlans.Add(mtmTestPlan.Name);
                        }
                    }
                }
            }

            //Set the datasource
            this.cboTestPlans.DataSource = testPlans;
        }