diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Microsoft.TeamServices.Samples.Client.csproj b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Microsoft.TeamServices.Samples.Client.csproj
index 9db55c4..739822c 100644
--- a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Microsoft.TeamServices.Samples.Client.csproj
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Microsoft.TeamServices.Samples.Client.csproj
@@ -53,70 +53,73 @@
..\packages\Microsoft.IdentityModel.Tokens.5.2.4\lib\net451\Microsoft.IdentityModel.Tokens.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll
+ ..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Common.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll
- ..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll
+ ..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Wiki.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Wiki.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.InteractiveClient.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll
+ ..\packages\Microsoft.VisualStudio.Services.InteractiveClient.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll
- ..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll
+ ..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll
- ..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.Release.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.Release.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.dll
+
+
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.dll
- ..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.TestResults.WebApi.dll
+ ..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.TestResults.WebApi.dll
- ..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll
+ ..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll
..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
@@ -177,6 +180,13 @@
+
+
+
+
+
+
+
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestCaseSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestCaseSample.cs
new file mode 100644
index 0000000..76ce738
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestCaseSample.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.TeamFoundation.TestManagement.WebApi;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+using SuiteEntry = Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.SuiteEntry;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestCaseProjectLocationIdString)]
+ public class TestCaseSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public void DeleteTestCase()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int testCaseId = this._getTestCaseId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ //Delete a test case
+ testPlanClient.DeleteTestCaseAsync(projectName, testCaseId).SyncResult();
+ }
+
+ //Dummy data
+ //Edit this for use.
+ private int _getTestCaseId()
+ {
+ return 99999999;
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestConfigurationSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestConfigurationSample.cs
new file mode 100644
index 0000000..6aab1ae
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestConfigurationSample.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.TeamFoundation.TestManagement.WebApi;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+using TestConfiguration = Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.TestConfiguration;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestConfigurationLocationIdString)]
+ public class TestConfigurationSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetTestConfigurations()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ // Get Test configurations
+ List configurations = testPlanClient.GetTestConfigurationsAsync(projectName).Result;
+
+
+ foreach (TestConfiguration configuration in configurations)
+ {
+ Context.Log("{0} {1}", configuration.Id.ToString().PadLeft(6), configuration.Name);
+ }
+ return configurations;
+ }
+
+ [ClientSampleMethod]
+ public TestConfiguration CreateTestConfiguration()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestConfigurationCreateUpdateParameters TestConfigurationCreateUpdateParameters = new TestConfigurationCreateUpdateParameters()
+ {
+ Name = "SampleTestConfiguration1",
+ Description = "Sample Test configuration",
+ IsDefault = true,
+ State = TeamFoundation.TestManagement.WebApi.TestConfigurationState.Active,
+ Values = new List()
+ {
+ new NameValuePair("Operating System", "Windows 8"),
+ }
+ };
+
+
+ // Create Test configuration
+ TestConfiguration configuration = testPlanClient.CreateTestConfigurationAsync(TestConfigurationCreateUpdateParameters, projectName).Result;
+
+
+ Context.SetValue("$newConfiguration", configuration);
+ Context.Log("{0} {1}", configuration.Id.ToString().PadLeft(6), configuration.Name);
+ return configuration;
+ }
+
+ [ClientSampleMethod]
+ public TestConfiguration GetTestConfigurationById()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestConfiguration newConfiguration;
+ Context.TryGetValue("$newConfiguration", out newConfiguration);
+ if (newConfiguration != null)
+ {
+ int id = newConfiguration.Id;
+
+
+ // Get Test configurations
+ TestConfiguration configuration = testPlanClient.GetTestConfigurationByIdAsync(projectName, id).Result;
+
+
+ Context.Log("{0} {1}", configuration.Id.ToString().PadLeft(6), configuration.Name);
+ return configuration;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public TestConfiguration UpdateTestConfiguration()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ TestConfiguration newConfiguration;
+ Context.TryGetValue("$newConfiguration", out newConfiguration);
+ if (newConfiguration != null)
+ {
+ int id = newConfiguration.Id;
+
+ //Get the test configuration first
+ TestConfiguration configuration = testPlanClient.GetTestConfigurationByIdAsync(projectName, id).Result;
+
+ //setting update params
+ 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;
+
+
+ Context.Log("{0} {1}", updatedconfiguration.Id.ToString().PadLeft(6), updatedconfiguration.Name);
+ return configuration;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public void DeleteTestConfiguration()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestConfiguration newConfiguration;
+ Context.TryGetValue("$newConfiguration", out newConfiguration);
+ if (newConfiguration != null)
+ {
+ int id = newConfiguration.Id;
+
+
+ //Delete the test configuration
+ testPlanClient.DeleteTestConfgurationAsync(projectName, id).SyncResult();
+ }
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestPlanSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestPlanSample.cs
new file mode 100644
index 0000000..4873f3a
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestPlanSample.cs
@@ -0,0 +1,307 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.TeamFoundation.TestManagement.WebApi;
+using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
+using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+using TestPlanWebApi = Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestPlanLocationIdString)]
+ public class TestPlanSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetTestPlans()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ // Get test plans
+ List plans = testPlanClient.GetTestPlansAsync(projectName).Result;
+
+
+ foreach (TestPlanWebApi.TestPlan plan in plans)
+ {
+ Context.Log("{0} {1}", plan.Id, plan.Name);
+ }
+ return plans;
+ }
+
+ [ClientSampleMethod]
+ public List GetActiveTestPlansFilteredByOwner()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ // Get test plans
+ List plans = testPlanClient.GetTestPlansAsync(projectName, includePlanDetails: true, filterActivePlans: true, owner: "0fdbdad8-6afb-6149-9af9-c0a216137d1d").Result;
+
+
+ foreach (TestPlanWebApi.TestPlan plan in plans)
+ {
+ Context.Log("{0} {1}", plan.Id, plan.Name);
+ }
+ return plans;
+ }
+
+ [ClientSampleMethod]
+ public TestPlanWebApi.TestPlan CreateTestPlanWithAreaPathAndIteration()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ 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("$newPlan1", plan);
+ Context.Log("{0} {1}", plan.Id, plan.Name);
+ return plan;
+ }
+
+ [ClientSampleMethod]
+ public TestPlanWebApi.TestPlan CreateTestPlan()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ BuildDefinitionReference buildDefinition = this._getBuildReference();
+ TestOutcomeSettings testOutcomeSettings = new TestOutcomeSettings()
+ {
+ SyncOutcomeAcrossSuites = true
+ };
+ ReleaseEnvironmentDefinitionReference releaseEnvironmentDefinition = this._getReleaseEnvironmentDefinitionReference();
+ TestPlanWebApi.TestPlanCreateParams testPlanCreateParams = new TestPlanWebApi.TestPlanCreateParams()
+ {
+ Name = "newCreatedPlan2",
+ 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(),
+ BuildDefinition = buildDefinition,
+ ReleaseEnvironmentDefinition = releaseEnvironmentDefinition,
+ TestOutcomeSettings = testOutcomeSettings
+ };
+
+
+ // create a test plan
+ TestPlanWebApi.TestPlan plan = testPlanClient.CreateTestPlanAsync(testPlanCreateParams, projectName).Result;
+
+
+ Context.SetValue("$newPlan2", plan);
+ Context.Log("{0} {1}", plan.Id, plan.Name);
+ return plan;
+ }
+
+ [ClientSampleMethod]
+ public TestPlanWebApi.TestPlan GetTestPlanById()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestPlanWebApi.TestPlan newplan1;
+ Context.TryGetValue("$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;
+ }
+
+ [ClientSampleMethod]
+ public TestPlanWebApi.TestPlan UpdateTestPlan()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ BuildDefinitionReference buildDefinition = this._getBuildReference();
+ TestOutcomeSettings testOutcomeSettings = new TestOutcomeSettings()
+ {
+ SyncOutcomeAcrossSuites = true
+ };
+ ReleaseEnvironmentDefinitionReference releaseEnvironmentDefinition = this._getReleaseEnvironmentDefinitionReference();
+
+
+ TestPlanWebApi.TestPlan newplan1;
+ Context.TryGetValue("$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;
+ }
+
+ [ClientSampleMethod]
+ public TestPlanWebApi.TestPlan UpdateTestPlanWithAreaPathAndIteration()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestPlanWebApi.TestPlan newplan2;
+ Context.TryGetValue("$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;
+ }
+
+ [ClientSampleMethod]
+ public void DeletePlanById_1()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestPlanWebApi.TestPlan newplan1;
+ Context.TryGetValue("$newPlan1", out newplan1);
+ if (newplan1 != null)
+ {
+ int id1 = newplan1.Id;
+
+
+ // Delete Test plan
+ testPlanClient.DeleteTestPlanAsync(projectName, id1).SyncResult();
+ }
+ }
+
+ [ClientSampleMethod]
+ public void DeletePlanById_2()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestPlanWebApi.TestPlan newplan2;
+ Context.TryGetValue("$newPlan2", out newplan2);
+ if (newplan2 != null)
+ {
+ int id2 = newplan2.Id;
+
+
+ // Delete Test plan
+ testPlanClient.DeleteTestPlanAsync(projectName, id2).SyncResult();
+ }
+ }
+
+ //Common dummy data
+ //Edit this for use.
+ private string _getArea()
+ {
+ return @"sampleProject\Team1";
+ }
+ private string _getIteration()
+ {
+ return @"sampleProject\Iteration 2";
+ }
+
+ private BuildDefinitionReference _getBuildReference()
+ {
+ int buildDefinitionId = 99999999;
+ return new BuildDefinitionReference(buildDefinitionId);
+ }
+
+ private int _getBuildId()
+ {
+ return 99999999;
+ }
+
+ private ReleaseEnvironmentDefinitionReference _getReleaseEnvironmentDefinitionReference()
+ {
+ int releaseDefiniteonId = 99999999;
+ int environmentId = 99999999;
+
+ return new ReleaseEnvironmentDefinitionReference()
+ {
+ DefinitionId = releaseDefiniteonId,
+ EnvironmentDefinitionId = environmentId
+ };
+ }
+
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteByCaseSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteByCaseSample.cs
new file mode 100644
index 0000000..603a5f3
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteByCaseSample.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestSuiteByCaseString)]
+ public class TestSuiteByCaseSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetTestSuitesByCase()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int testCaseId = this._getTestCaseId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ // Get Test Suites for a test case
+ List testSuites = testPlanClient.GetSuitesByTestCaseIdAsync(testCaseId).Result;
+
+
+ foreach (TestSuite testSuite in testSuites)
+ {
+ Context.Log("{0} {1}", testSuite.Id.ToString().PadLeft(6), testSuite.Name);
+ }
+ return testSuites;
+ }
+
+
+ //Dummy data
+ //Edit this for use.
+ private int _getTestCaseId()
+ {
+ return 99999999;
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteEntrySample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteEntrySample.cs
new file mode 100644
index 0000000..3631e6d
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteEntrySample.cs
@@ -0,0 +1,353 @@
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+using System.Collections.Generic;
+using SuiteEntry = Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.SuiteEntry;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestSuiteEntryProjectLocationIdString)]
+ public class TestSuiteEntrySample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetSuiteEntries()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ //get suite entries
+ List suiteEntries = testPlanClient.GetSuiteEntriesAsync(projectName, suiteId).Result;
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ [ClientSampleMethod]
+ public List GetChildSuiteEntries()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+
+ //get suite entries
+ List suiteEntries = testPlanClient.GetSuiteEntriesAsync(projectName, suiteId, SuiteEntryTypes.Suite).Result;
+
+
+ Context.SetValue>("$childSuiteEntries", suiteEntries);
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ [ClientSampleMethod]
+ public List GetTestCaseEntries()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ //get suite entries
+ List suiteEntries = testPlanClient.GetSuiteEntriesAsync(projectName, suiteId, SuiteEntryTypes.TestCase).Result;
+
+
+ Context.SetValue>("$testCaseEntries", suiteEntries);
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ [ClientSampleMethod]
+ public List UpdateTestCaseEntryOrder()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ List testCases;
+ Context.TryGetValue>("$testCaseEntries", out testCases);
+
+ if (testCases != null && testCases.Count >= 2)
+ {
+ SuiteEntry testCase1 = testCases[0];
+ SuiteEntry testCase2 = testCases[1];
+
+ SuiteEntryUpdateParams suiteEntry1 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase1.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = testCase2.SequenceNumber
+ };
+
+ SuiteEntryUpdateParams suiteEntry2 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase2.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = testCase1.SequenceNumber
+ };
+
+ List updatedEntries = new List()
+ {
+ suiteEntry1,
+ suiteEntry2
+ };
+
+
+
+ //update suite entries
+ List suiteEntries = testPlanClient.ReorderSuiteEntriesAsync(updatedEntries, projectName, suiteId).Result;
+
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public List UpdateChildSuiteEntryOrder()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ List childSuites;
+ Context.TryGetValue>("$childSuiteEntries", out childSuites);
+
+ if (childSuites != null && childSuites.Count >= 2)
+ {
+ SuiteEntry childSuite1 = childSuites[0];
+ SuiteEntry childSuite2 = childSuites[1];
+
+ SuiteEntryUpdateParams suiteEntry1 = new SuiteEntryUpdateParams()
+ {
+ Id = childSuite1.Id,
+ SuiteEntryType = SuiteEntryTypes.Suite,
+ SequenceNumber = childSuite2.SequenceNumber
+ };
+
+ SuiteEntryUpdateParams suiteEntry2 = new SuiteEntryUpdateParams()
+ {
+ Id = childSuite2.Id,
+ SuiteEntryType = SuiteEntryTypes.Suite,
+ SequenceNumber = childSuite1.SequenceNumber
+ };
+
+ List updatedEntries = new List()
+ {
+ suiteEntry1,
+ suiteEntry2
+ };
+
+
+
+ //update suite entries
+ List suiteEntries = testPlanClient.ReorderSuiteEntriesAsync(updatedEntries, projectName, suiteId).Result;
+
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public List UpdateTestCaseAndChildSuiteEntryOrder()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ List childSuites;
+ Context.TryGetValue>("$childSuiteEntries", out childSuites);
+
+ List testCases;
+ Context.TryGetValue>("$testCaseEntries", out testCases);
+
+ if (childSuites != null && childSuites.Count >= 2 && testCases != null && testCases.Count >= 2)
+ {
+ SuiteEntry testCase2 = testCases[0];
+ SuiteEntry childSuite2 = childSuites[0];
+
+ SuiteEntryUpdateParams suiteEntry1 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase2.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = 0
+ };
+
+ SuiteEntryUpdateParams suiteEntry2 = new SuiteEntryUpdateParams()
+ {
+ Id = childSuite2.Id,
+ SuiteEntryType = SuiteEntryTypes.Suite,
+ SequenceNumber = 0
+ };
+
+ List updatedEntries = new List()
+ {
+ suiteEntry1,
+ suiteEntry2
+ };
+
+
+
+ //update suite entries
+ List suiteEntries = testPlanClient.ReorderSuiteEntriesAsync(updatedEntries, projectName, suiteId).Result;
+
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public List UpdateTestCaseEntryOrderWithConflcitingSequenceNumber()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ List testCases;
+ Context.TryGetValue>("$testCaseEntries", out testCases);
+
+ if (testCases != null && testCases.Count >= 2)
+ {
+ SuiteEntry testCase1 = testCases[0];
+ SuiteEntry testCase2 = testCases[1];
+
+ SuiteEntryUpdateParams suiteEntry1 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase1.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = 0
+ };
+
+ SuiteEntryUpdateParams suiteEntry2 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase2.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = 0
+ };
+
+ List updatedEntries = new List()
+ {
+ suiteEntry1,
+ suiteEntry2
+ };
+
+
+ //update suite entries
+ List suiteEntries = testPlanClient.ReorderSuiteEntriesAsync(updatedEntries, projectName, suiteId).Result;
+
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public List UpdateTestCaseEntryOrderWithOverflowingSequenceOrder()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int suiteId = this._getTestSuiteId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ List testCases;
+ Context.TryGetValue>("$testCaseEntries", out testCases);
+
+ if (testCases != null && testCases.Count >= 1)
+ {
+ SuiteEntry testCase1 = testCases[0];
+
+ SuiteEntryUpdateParams suiteEntry1 = new SuiteEntryUpdateParams()
+ {
+ Id = testCase1.Id,
+ SuiteEntryType = SuiteEntryTypes.TestCase,
+ SequenceNumber = 9999999
+ };
+
+ List updatedEntries = new List()
+ {
+ suiteEntry1
+ };
+
+
+ //update suite entries
+ List suiteEntries = testPlanClient.ReorderSuiteEntriesAsync(updatedEntries, projectName, suiteId).Result;
+
+
+ foreach (SuiteEntry suiteEntry in suiteEntries)
+ {
+ Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
+ }
+ return suiteEntries;
+ }
+
+ return null;
+ }
+
+ //Common dummy data
+ //Edit this for use.
+ private int _getTestSuiteId()
+ {
+ return 99999999;
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteSample.cs
new file mode 100644
index 0000000..ce9a178
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestSuiteSample.cs
@@ -0,0 +1,214 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestSuiteProjectLocationIdString)]
+ public class TestSuiteSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetTestSuitesForPlan()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int testPlanId = this._getTestPlanId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ // Get Test Suites
+ List testSuites = testPlanClient.GetTestSuitesForPlanAsync(projectName, testPlanId, SuiteExpand.Children | SuiteExpand.DefaultTesters).Result;
+
+ foreach (TestSuite testSuite in testSuites)
+ {
+ Context.Log("{0} {1}", testSuite.Id.ToString().PadLeft(6), testSuite.Name);
+ }
+ return testSuites;
+ }
+
+ [ClientSampleMethod]
+ public List GetTestSuitesAsTreeView()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int testPlanId = this._getTestPlanId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ // Get Test Suites
+ List testSuites = testPlanClient.GetTestSuitesForPlanAsync(projectName, testPlanId, asTreeView: true).Result;
+
+ return testSuites;
+ }
+
+
+ [ClientSampleMethod]
+ public TestSuite CreateTestSuite()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ int testPlanId = this._getTestPlanId();
+
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ int parentSuiteId = this._getRootSuiteId();
+ TestSuiteCreateParams testSuiteCreateParams = new TestSuiteCreateParams()
+ {
+ Name = "SubSuite 1.1.1",
+ SuiteType = TestSuiteType.StaticTestSuite,
+ ParentSuite = new TestSuiteReference()
+ {
+ Id = parentSuiteId
+ },
+ InheritDefaultConfigurations = false,
+ DefaultConfigurations = new List()
+ {
+ new TestConfigurationReference(){Id=1},
+ new TestConfigurationReference(){Id=2}
+ }
+ };
+
+ // Create Test Suite
+ TestSuite suite = testPlanClient.CreateTestSuiteAsync(testSuiteCreateParams, projectName, testPlanId).Result;
+
+ Context.SetValue("$newSuite", suite);
+ Context.Log("{0} {1}", suite.Id.ToString().PadLeft(6), suite.Name);
+ return suite;
+ }
+
+ [ClientSampleMethod]
+ public TestSuite GetTestSuiteById()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ int testPlanId = this._getTestPlanId();
+ TestSuite newSuite;
+ Context.TryGetValue("$newSuite", out newSuite);
+ int id = newSuite.Id;
+ if (id != 0)
+ {
+ // Get Test Suite
+ TestSuite suite = testPlanClient.GetTestSuiteByIdAsync(projectName, testPlanId, id, SuiteExpand.Children).Result;
+
+ Context.Log("{0} {1}", suite.Id.ToString().PadLeft(6), suite.Name);
+ return suite;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public TestSuite UpdateTestSuiteParent()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+
+ TestSuiteUpdateParams testSuiteUpdateParams = new TestSuiteUpdateParams()
+ {
+ ParentSuite = new TestSuiteReference()
+ {
+ Id = this._getUpdatedRootSuiteId()
+ }
+ };
+
+ int testPlanId = this._getTestPlanId();
+ TestSuite newSuite;
+ Context.TryGetValue("$newSuite", out newSuite);
+ if (newSuite != null)
+ {
+ int id = newSuite.Id;
+
+ // Update Test Suite
+ TestSuite updtaetdTestSuite = testPlanClient.UpdateTestSuiteAsync(testSuiteUpdateParams, projectName, testPlanId, id).Result;
+
+ Context.Log("{0} {1}", updtaetdTestSuite.Id.ToString().PadLeft(6), updtaetdTestSuite.Name);
+ return updtaetdTestSuite;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public TestSuite UpdateTestSuiteProperties()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestSuiteUpdateParams testSuiteUpdateParams = new TestSuiteUpdateParams()
+ {
+ DefaultTesters = new List()
+ {
+ new IdentityRef()
+ {
+ Id = this._getDefaultTesterIdentity()
+ }
+ }
+ };
+
+ int testPlanId = this._getTestPlanId();
+ TestSuite newSuite;
+ Context.TryGetValue("$newSuite", out newSuite);
+ if (newSuite != null)
+ {
+ int id = newSuite.Id;
+ TestSuite updtaetdTestSuite = testPlanClient.UpdateTestSuiteAsync(testSuiteUpdateParams, projectName, testPlanId, id).Result;
+ Context.Log("{0} {1}", updtaetdTestSuite.Id.ToString().PadLeft(6), updtaetdTestSuite.Name);
+ return updtaetdTestSuite;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public void DeleteTestSuite()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ int testPlanId = this._getTestPlanId();
+ TestSuite newSuite;
+ Context.TryGetValue("$newSuite", out newSuite);
+ if (newSuite != null)
+ {
+ int id = newSuite.Id;
+
+ //Delete Test Suite
+ testPlanClient.DeleteTestSuiteAsync(projectName, testPlanId, id).SyncResult();
+ }
+ }
+
+ //Common dummy data
+ //Edit this for use.
+ private int _getTestPlanId()
+ {
+ return 99999999;
+ }
+
+ private int _getRootSuiteId()
+ {
+ return 99999999;
+ }
+
+ private int _getUpdatedRootSuiteId()
+ {
+ return 99999999;
+ }
+
+ private string _getDefaultTesterIdentity()
+ {
+ return "0fdbdad8-6afb-6149-9af9-c0a216137d1d";
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestVariableSample.cs b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestVariableSample.cs
new file mode 100644
index 0000000..63d055d
--- /dev/null
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Test/TestVariableSample.cs
@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi;
+using Microsoft.VisualStudio.Services.WebApi;
+
+namespace Microsoft.TeamServices.Samples.Client.Test
+{
+ [ClientSample(TestPlanResourceIds.AreaName, TestPlanResourceIds.TestVariableLocationIdString)]
+ public class TestVariableSample : ClientSample
+ {
+ [ClientSampleMethod]
+ public List GetTestVariables()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ // Get Test Variables
+ List variables = testPlanClient.GetTestVariablesAsync(projectName).Result;
+
+ foreach (TestVariable variable in variables)
+ {
+ Context.Log("{0} {1}", variable.Id.ToString().PadLeft(6), variable.Name);
+ }
+ return variables;
+ }
+
+ [ClientSampleMethod]
+ public TestVariable CreateTestVariable()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestVariableCreateUpdateParameters testVariableCreateUpdateParameters = new TestVariableCreateUpdateParameters()
+ {
+ Name = "SampleTestVariable1",
+ Description = "Sample Test Variable",
+ Values = new List()
+ {
+ "Test Value 1",
+ "Test Value 2"
+ }
+ };
+
+ // Create Test Variable
+ TestVariable variable = testPlanClient.CreateTestVariableAsync(testVariableCreateUpdateParameters, projectName).Result;
+
+ Context.SetValue("$newVariable", variable);
+ Context.Log("{0} {1}", variable.Id.ToString().PadLeft(6), variable.Name);
+ return variable;
+ }
+
+ [ClientSampleMethod]
+ public TestVariable GetTestVariableById()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestVariable newVariable;
+ Context.TryGetValue("$newVariable", out newVariable);
+ if (newVariable != null)
+ {
+ int id = newVariable.Id;
+
+ // Get Test Variable
+ TestVariable variable = testPlanClient.GetTestVariableByIdAsync(projectName, id).Result;
+
+ Context.Log("{0} {1}", variable.Id.ToString().PadLeft(6), variable.Name);
+ return variable;
+ }
+ return null;
+ }
+
+ [ClientSampleMethod]
+ public TestVariable UpdateTestVariable()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ //Get the test variable first
+ TestVariable newVariable;
+ Context.TryGetValue("$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;
+ }
+
+ [ClientSampleMethod]
+ public void DeleteTestVariable()
+ {
+ string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
+ // Get a testplan client instance
+ VssConnection connection = Context.Connection;
+ TestPlanHttpClient testPlanClient = connection.GetClient();
+
+ TestVariable newVariable;
+ Context.TryGetValue("$newVariable", out newVariable);
+ if (newVariable != null)
+ {
+ int id = newVariable.Id;
+
+ //Delete the test variable
+ testPlanClient.DeleteTestVariableAsync(projectName, id).SyncResult();
+ }
+ }
+ }
+}
diff --git a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/packages.config b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/packages.config
index dc8ea7e..372de81 100644
--- a/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/packages.config
+++ b/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/packages.config
@@ -8,16 +8,16 @@
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+