public TestPlanWebApi.TestPlan UpdateTestPlanWithAreaPathAndIteration()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            TestPlanWebApi.TestPlan newplan2;
            Context.TryGetValue <TestPlanWebApi.TestPlan>("$newPlan2", out newplan2);
            if (newplan2 != null)
            {
                int id = newplan2.Id;
                TestPlanWebApi.TestPlanUpdateParams testPlanUpdateParams = new TestPlanWebApi.TestPlanUpdateParams()
                {
                    Name      = "updatedPlan2",
                    AreaPath  = this._getArea(),
                    Iteration = this._getIteration()
                };


                // update a test plan
                TestPlanWebApi.TestPlan plan = testPlanClient.UpdateTestPlanAsync(testPlanUpdateParams, projectName, id).Result;


                Context.Log("{0} {1}", plan.Id, plan.Name);
                return(plan);
            }
            return(null);
        }
        public TestPlanWebApi.TestPlan UpdateTestPlan()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            BuildDefinitionReference buildDefinition     = this._getBuildReference();
            TestOutcomeSettings      testOutcomeSettings = new TestOutcomeSettings()
            {
                SyncOutcomeAcrossSuites = true
            };
            ReleaseEnvironmentDefinitionReference releaseEnvironmentDefinition = this._getReleaseEnvironmentDefinitionReference();


            TestPlanWebApi.TestPlan newplan1;
            Context.TryGetValue <TestPlanWebApi.TestPlan>("$newPlan1", out newplan1);
            if (newplan1 != null)
            {
                int id = newplan1.Id;
                TestPlanWebApi.TestPlanUpdateParams testPlanUpdateParams = new TestPlanWebApi.TestPlanUpdateParams()
                {
                    Name            = "updatedPlan1",
                    AreaPath        = this._getArea(),
                    Iteration       = this._getIteration(),
                    Description     = "description of the test plan",
                    StartDate       = DateTime.Now.AddDays(2),
                    EndDate         = DateTime.Now.AddDays(9),
                    State           = "Inactive",
                    BuildId         = this._getBuildId(),
                    Revision        = newplan1.Revision,
                    BuildDefinition = buildDefinition,
                    ReleaseEnvironmentDefinition = releaseEnvironmentDefinition,
                    TestOutcomeSettings          = testOutcomeSettings
                };


                // update a test plan
                TestPlanWebApi.TestPlan plan = testPlanClient.UpdateTestPlanAsync(testPlanUpdateParams, projectName, id).Result;


                Context.Log("{0} {1}", plan.Id, plan.Name);
                return(plan);
            }
            return(null);
        }
        public TestPlanWebApi.TestPlan CreateTestPlanWithAreaPathAndIteration()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            TestPlanWebApi.TestPlanCreateParams testPlanCreateParams = new TestPlanWebApi.TestPlanCreateParams()
            {
                Name      = "newCreatedPlan1",
                AreaPath  = this._getArea(),
                Iteration = this._getIteration()
            };


            // create a test plan
            TestPlanWebApi.TestPlan plan = testPlanClient.CreateTestPlanAsync(testPlanCreateParams, projectName).Result;


            Context.SetValue <TestPlanWebApi.TestPlan>("$newPlan1", plan);
            Context.Log("{0} {1}", plan.Id, plan.Name);
            return(plan);
        }
        public TestPlanWebApi.TestPlan GetTestPlanById()
        {
            string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;

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

            TestPlanWebApi.TestPlan newplan1;
            Context.TryGetValue <TestPlanWebApi.TestPlan>("$newPlan1", out newplan1);
            if (newplan1 != null)
            {
                int id = newplan1.Id;


                // get a test plan
                TestPlanWebApi.TestPlan plan = testPlanClient.GetTestPlanByIdAsync(projectName, id).Result;


                Context.Log("{0} {1}", plan.Id, plan.Name);
                return(plan);
            }
            return(null);
        }