예제 #1
0
        public TestVariable UpdateTestVariable()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
            // Get a testplan client instance
            VssConnection      connection     = Context.Connection;
            TestPlanHttpClient testPlanClient = connection.GetClient <TestPlanHttpClient>();

            //Get the test variable first
            TestVariable newVariable;

            Context.TryGetValue <TestVariable>("$newVariable", out newVariable);
            if (newVariable != null)
            {
                int id = newVariable.Id;

                TestVariable variable = testPlanClient.GetTestVariableByIdAsync(projectName, id).Result;
                TestVariableCreateUpdateParameters testVariableCreateUpdateParameters = new TestVariableCreateUpdateParameters()
                {
                    Name        = variable.Name,
                    Description = "Updated Description",
                    Values      = variable.Values
                };
                testVariableCreateUpdateParameters.Values.Add("New Value");

                // Update Test Variable
                TestVariable updatedVariable = testPlanClient.UpdateTestVariableAsync(testVariableCreateUpdateParameters, projectName, variable.Id).Result;

                Context.Log("{0} {1}", updatedVariable.Id.ToString().PadLeft(6), updatedVariable.Name);
                return(variable);
            }
            return(null);
        }