зеркало из
1
0
Форкнуть 0
This commit is contained in:
viradhamMS 2018-10-19 22:46:02 +05:30 коммит произвёл Dan Hellem
Родитель 6b5998abca
Коммит 4aad11186e
9 изменённых файлов: 1270 добавлений и 31 удалений

Просмотреть файл

@ -53,70 +53,73 @@
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.2.4\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Build2.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Build2.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Common, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Core.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Core.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Dashboards.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Dashboards.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.DistributedTask.Common.Contracts, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Policy.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Policy.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.SourceControl.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.SourceControl.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Test.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Test.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.TestManagement.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.TestManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Wiki.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Wiki.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Wiki.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Work.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.Work.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Client.Interactive, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.InteractiveClient.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.InteractiveClient.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Client.Interactive.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Common, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ExtensionManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Gallery.WebApi, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Gallery.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Gallery.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.Notifications.WebApi, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Notifications.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.Notifications.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.ReleaseManagement.WebApi, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Release.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Release.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.ServiceHooks.WebApi, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.ServiceHooks.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.TestResults.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.TestResults.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.TeamFoundationServer.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.TestResults.WebApi.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Services.WebApi, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.139.0-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
<HintPath>..\packages\Microsoft.VisualStudio.Services.Client.16.141.1-preview\lib\net45\Microsoft.VisualStudio.Services.WebApi.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
@ -177,6 +180,13 @@
<Compile Include="Security\TokenHelpers.cs" />
<Compile Include="Security\SecurityNamespacesSample.cs" />
<Compile Include="Hooks\SubscriptionsSample.cs" />
<Compile Include="Test\TestCaseSample.cs" />
<Compile Include="Test\TestConfigurationSample.cs" />
<Compile Include="Test\TestPlanSample.cs" />
<Compile Include="Test\TestSuiteByCaseSample.cs" />
<Compile Include="Test\TestSuiteEntrySample.cs" />
<Compile Include="Test\TestSuiteSample.cs" />
<Compile Include="Test\TestVariableSample.cs" />
<Compile Include="Tfvc\ItemsSample.cs" />
<Compile Include="Tfvc\ChangesetChangesSample.cs" />
<Compile Include="Tfvc\BranchesSample.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<TestPlanHttpClient>();
//Delete a test case
testPlanClient.DeleteTestCaseAsync(projectName, testCaseId).SyncResult();
}
//Dummy data
//Edit this for use.
private int _getTestCaseId()
{
return 99999999;
}
}
}

Просмотреть файл

@ -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<TestConfiguration> GetTestConfigurations()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
// Get Test configurations
List<TestConfiguration> 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<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;
}
[ClientSampleMethod]
public TestConfiguration GetTestConfigurationById()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
TestConfiguration newConfiguration;
Context.TryGetValue<TestConfiguration>("$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<TestPlanHttpClient>();
TestConfiguration newConfiguration;
Context.TryGetValue<TestConfiguration>("$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<TestPlanHttpClient>();
TestConfiguration newConfiguration;
Context.TryGetValue<TestConfiguration>("$newConfiguration", out newConfiguration);
if (newConfiguration != null)
{
int id = newConfiguration.Id;
//Delete the test configuration
testPlanClient.DeleteTestConfgurationAsync(projectName, id).SyncResult();
}
}
}
}

Просмотреть файл

@ -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<TestPlanWebApi.TestPlan> GetTestPlans()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
// Get test plans
List<TestPlanWebApi.TestPlan> plans = testPlanClient.GetTestPlansAsync(projectName).Result;
foreach (TestPlanWebApi.TestPlan plan in plans)
{
Context.Log("{0} {1}", plan.Id, plan.Name);
}
return plans;
}
[ClientSampleMethod]
public List<TestPlanWebApi.TestPlan> GetActiveTestPlansFilteredByOwner()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
// Get test plans
List<TestPlanWebApi.TestPlan> 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<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;
}
[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<TestPlanHttpClient>();
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<TestPlanWebApi.TestPlan>("$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<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;
}
[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<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;
}
[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<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;
}
[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<TestPlanHttpClient>();
TestPlanWebApi.TestPlan newplan1;
Context.TryGetValue<TestPlanWebApi.TestPlan>("$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<TestPlanHttpClient>();
TestPlanWebApi.TestPlan newplan2;
Context.TryGetValue<TestPlanWebApi.TestPlan>("$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
};
}
}
}

Просмотреть файл

@ -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<TestSuite> 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<TestPlanHttpClient>();
// Get Test Suites for a test case
List<TestSuite> 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;
}
}
}

Просмотреть файл

@ -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<SuiteEntry> 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<TestPlanHttpClient>();
//get suite entries
List<SuiteEntry> 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<SuiteEntry> 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<TestPlanHttpClient>();
//get suite entries
List<SuiteEntry> suiteEntries = testPlanClient.GetSuiteEntriesAsync(projectName, suiteId, SuiteEntryTypes.Suite).Result;
Context.SetValue<List<SuiteEntry>>("$childSuiteEntries", suiteEntries);
foreach (SuiteEntry suiteEntry in suiteEntries)
{
Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
}
return suiteEntries;
}
[ClientSampleMethod]
public List<SuiteEntry> 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<TestPlanHttpClient>();
//get suite entries
List<SuiteEntry> suiteEntries = testPlanClient.GetSuiteEntriesAsync(projectName, suiteId, SuiteEntryTypes.TestCase).Result;
Context.SetValue<List<SuiteEntry>>("$testCaseEntries", suiteEntries);
foreach (SuiteEntry suiteEntry in suiteEntries)
{
Context.Log("{0} {1}", suiteEntry.Id.ToString().PadLeft(6), suiteEntry.SequenceNumber);
}
return suiteEntries;
}
[ClientSampleMethod]
public List<SuiteEntry> 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<TestPlanHttpClient>();
List<SuiteEntry> testCases;
Context.TryGetValue<List<SuiteEntry>>("$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<SuiteEntryUpdateParams> updatedEntries = new List<SuiteEntryUpdateParams>()
{
suiteEntry1,
suiteEntry2
};
//update suite entries
List<SuiteEntry> 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<SuiteEntry> 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<TestPlanHttpClient>();
List<SuiteEntry> childSuites;
Context.TryGetValue<List<SuiteEntry>>("$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<SuiteEntryUpdateParams> updatedEntries = new List<SuiteEntryUpdateParams>()
{
suiteEntry1,
suiteEntry2
};
//update suite entries
List<SuiteEntry> 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<SuiteEntry> 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<TestPlanHttpClient>();
List<SuiteEntry> childSuites;
Context.TryGetValue<List<SuiteEntry>>("$childSuiteEntries", out childSuites);
List<SuiteEntry> testCases;
Context.TryGetValue<List<SuiteEntry>>("$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<SuiteEntryUpdateParams> updatedEntries = new List<SuiteEntryUpdateParams>()
{
suiteEntry1,
suiteEntry2
};
//update suite entries
List<SuiteEntry> 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<SuiteEntry> 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<TestPlanHttpClient>();
List<SuiteEntry> testCases;
Context.TryGetValue<List<SuiteEntry>>("$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<SuiteEntryUpdateParams> updatedEntries = new List<SuiteEntryUpdateParams>()
{
suiteEntry1,
suiteEntry2
};
//update suite entries
List<SuiteEntry> 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<SuiteEntry> 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<TestPlanHttpClient>();
List<SuiteEntry> testCases;
Context.TryGetValue<List<SuiteEntry>>("$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<SuiteEntryUpdateParams> updatedEntries = new List<SuiteEntryUpdateParams>()
{
suiteEntry1
};
//update suite entries
List<SuiteEntry> 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;
}
}
}

Просмотреть файл

@ -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<TestSuite> 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<TestPlanHttpClient>();
// Get Test Suites
List<TestSuite> 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<TestSuite> 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<TestPlanHttpClient>();
// Get Test Suites
List<TestSuite> 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<TestPlanHttpClient>();
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<TestConfigurationReference>()
{
new TestConfigurationReference(){Id=1},
new TestConfigurationReference(){Id=2}
}
};
// Create Test Suite
TestSuite suite = testPlanClient.CreateTestSuiteAsync(testSuiteCreateParams, projectName, testPlanId).Result;
Context.SetValue<TestSuite>("$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<TestPlanHttpClient>();
int testPlanId = this._getTestPlanId();
TestSuite newSuite;
Context.TryGetValue<TestSuite>("$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<TestPlanHttpClient>();
TestSuiteUpdateParams testSuiteUpdateParams = new TestSuiteUpdateParams()
{
ParentSuite = new TestSuiteReference()
{
Id = this._getUpdatedRootSuiteId()
}
};
int testPlanId = this._getTestPlanId();
TestSuite newSuite;
Context.TryGetValue<TestSuite>("$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<TestPlanHttpClient>();
TestSuiteUpdateParams testSuiteUpdateParams = new TestSuiteUpdateParams()
{
DefaultTesters = new List<IdentityRef>()
{
new IdentityRef()
{
Id = this._getDefaultTesterIdentity()
}
}
};
int testPlanId = this._getTestPlanId();
TestSuite newSuite;
Context.TryGetValue<TestSuite>("$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<TestPlanHttpClient>();
int testPlanId = this._getTestPlanId();
TestSuite newSuite;
Context.TryGetValue<TestSuite>("$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";
}
}
}

Просмотреть файл

@ -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<TestVariable> GetTestVariables()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
// Get Test Variables
List<TestVariable> 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<TestPlanHttpClient>();
TestVariableCreateUpdateParameters testVariableCreateUpdateParameters = new TestVariableCreateUpdateParameters()
{
Name = "SampleTestVariable1",
Description = "Sample Test Variable",
Values = new List<string>()
{
"Test Value 1",
"Test Value 2"
}
};
// Create Test Variable
TestVariable variable = testPlanClient.CreateTestVariableAsync(testVariableCreateUpdateParameters, projectName).Result;
Context.SetValue<TestVariable>("$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<TestPlanHttpClient>();
TestVariable newVariable;
Context.TryGetValue<TestVariable>("$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<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;
}
[ClientSampleMethod]
public void DeleteTestVariable()
{
string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name;
// Get a testplan client instance
VssConnection connection = Context.Connection;
TestPlanHttpClient testPlanClient = connection.GetClient<TestPlanHttpClient>();
TestVariable newVariable;
Context.TryGetValue<TestVariable>("$newVariable", out newVariable);
if (newVariable != null)
{
int id = newVariable.Id;
//Delete the test variable
testPlanClient.DeleteTestVariableAsync(projectName, id).SyncResult();
}
}
}
}

Просмотреть файл

@ -8,16 +8,16 @@
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.2.4" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Logging" version="5.2.4" targetFramework="net452" />
<package id="Microsoft.IdentityModel.Tokens" version="5.2.4" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundation.DistributedTask.Common.Contracts" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.TeamFoundationServer.Client" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Gallery.WebApi" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.InteractiveClient" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Release.Client" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ServiceHooks.WebApi" version="16.139.0-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Client" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ExtensionManagement.WebApi" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Gallery.WebApi" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.InteractiveClient" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Notifications.WebApi" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.Release.Client" version="16.141.1-preview" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Services.ServiceHooks.WebApi" version="16.141.1-preview" targetFramework="net452" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.2.4" targetFramework="net452" />
<package id="WindowsAzure.ServiceBus" version="5.0.0" targetFramework="net452" />