public TestConfiguration CreateTestConfiguration()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();

            TestConfigurationCreateUpdateParameters TestConfigurationCreateUpdateParameters = new TestConfigurationCreateUpdateParameters()
            {
                Name        = "SampleTestConfiguration1",
                Description = "Sample Test configuration",
                IsDefault   = true,
                State       = TeamFoundation.TestManagement.WebApi.TestConfigurationState.Active,
                Values      = new List <NameValuePair>()
                {
                    new NameValuePair("Operating System", "Windows 8"),
                }
            };


            // Create Test configuration
            TestConfiguration configuration = testPlanClient.CreateTestConfigurationAsync(TestConfigurationCreateUpdateParameters, projectName).Result;


            Context.SetValue <TestConfiguration>("$newConfiguration", configuration);
            Context.Log("{0} {1}", configuration.Id.ToString().PadLeft(6), configuration.Name);
            return(configuration);
        }
コード例 #2
0
        public TestConfiguration UpdateTestConfiguration()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();

            //Get the test configuration first
            TestConfiguration configuration = testPlanClient.GetTestConfigurationByIdAsync(projectName, 8).Result;

            TestConfigurationCreateUpdateParameters TestConfigurationCreateUpdateParameters = new TestConfigurationCreateUpdateParameters()
            {
                Name        = configuration.Name,
                Description = "Updated Description",
                Values      = configuration.Values
            };

            TestConfigurationCreateUpdateParameters.Values.Add(new NameValuePair("Browser", "Microsoft Edge"));

            // Update Test configuration
            TestConfiguration updatedconfiguration = testPlanClient.UpdateTestConfigurationAsync(TestConfigurationCreateUpdateParameters, projectName, configuration.Id).Result;

            Console.WriteLine("{0} {1}", updatedconfiguration.Id.ToString().PadLeft(6), updatedconfiguration.Name);

            return(configuration);
        }