зеркало из
1
0
Форкнуть 0
This commit is contained in:
Dan Hellem 2017-01-12 13:42:48 -08:00
Родитель 06df3d838b
Коммит b69dd28569
10 изменённых файлов: 203 добавлений и 19 удалений

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

@ -81,9 +81,10 @@
<Compile Include="WorkItemTracking\BatchTest.cs" />
<Compile Include="WorkItemTracking\ReportingTest.cs" />
<Compile Include="WorkItemTracking\WorkItemsTest.cs" />
<Compile Include="Work\ProcessConfiguration\ListsTest.cs" />
<Compile Include="Work\ProcessConfiguration\FieldsTest.cs" />
<Compile Include="Work\ListsTest.cs" />
<Compile Include="Work\FieldsTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Work\TeamSettingsTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">

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

@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VstsRestApiSamples.Work.ProcessConfiguration;
using VstsRestApiSamples.Work;
using System.Net;
namespace VstsRestApiSamples.Tests.Work.ProcessConfiguration
{
namespace VstsRestApiSamples.Tests.Work
{
[TestClass]
public class FieldsTest
{

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

@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using VstsRestApiSamples.Work.ProcessConfiguration;
using VstsRestApiSamples.Work;
namespace VstsRestApiSamples.Tests.Work.ProcessConfiguration
namespace VstsRestApiSamples.Tests.Work
{
[TestClass]
public class ListTests

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

@ -0,0 +1,42 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VstsRestApiSamples.Work;
using VstsRestApiSamples.ViewModels.Work;
using System.Net;
namespace VstsRestApiSamples.Tests.Work
{
[TestClass]
public class TeamSettingsTest
{
private IConfiguration _configuration = new Configuration();
[TestInitialize]
public void TestInitialize()
{
InitHelper.GetConfiguration(_configuration);
}
[TestCleanup]
public void TestCleanup()
{
_configuration = null;
}
[TestMethod, TestCategory("REST API")]
public void WorkItemTracking_WorkItems_GetWorkItemsByIDs_Success()
{
// arrange
TeamSettings request = new TeamSettings(_configuration);
// act
GetTeamSettingsResponse.Settings response = request.GetTeamsSettings(_configuration.Project, _configuration.Team);
// assert
Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode);
request = null;
}
}
}

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

@ -67,18 +67,23 @@ namespace VstsRestApiSamples.Tests.WorkItemTracking
RecycleBin recyclebinRequest = new RecycleBin(_configuration);
// act
//WorkItemPatchResponse.WorkItem createResponse = workItemsRequest.CreateWorkItem(_configuration.Project);
//WorkItemPatchResponse.WorkItem deleteResponse = workItemsRequest.DeleteWorkItem(createResponse.id.ToString());
//GetItemFromRecycleBinResponse.WorkItem getDeletedItemResponse = recyclebinRequest.GetDeletedItem(_configuration.Project, createResponse.id.ToString());
System.Net.HttpStatusCode restoreResponse = recyclebinRequest.RestoreWorkItem(_configuration.Project, "3212");
WorkItemPatchResponse.WorkItem createResponse = workItemsRequest.CreateWorkItem(_configuration.Project);
WorkItemPatchResponse.WorkItem deleteResponse = workItemsRequest.DeleteWorkItem(createResponse.id.ToString());
GetItemFromRecycleBinResponse.WorkItem getDeletedItemResponse = recyclebinRequest.GetDeletedItem(_configuration.Project, createResponse.id.ToString());
System.Net.HttpStatusCode restoreResponse = recyclebinRequest.RestoreWorkItem(_configuration.Project, createResponse.id.ToString());
////get restored item
GetWorkItemExpandAllResponse.WorkItem getRestoredItemResponse = workItemsRequest.GetWorkItem(createResponse.id.ToString());
//assert
//Assert.AreEqual(HttpStatusCode.OK, createResponse.HttpStatusCode);
//Assert.AreEqual(HttpStatusCode.OK, deleteResponse.HttpStatusCode);
//Assert.AreEqual(HttpStatusCode.OK, getDeletedItemResponse.HttpStatusCode);
Assert.AreEqual(HttpStatusCode.OK, restoreResponse);
Assert.AreEqual(HttpStatusCode.OK, createResponse.HttpStatusCode);
Assert.AreEqual(HttpStatusCode.OK, deleteResponse.HttpStatusCode);
Assert.AreEqual(HttpStatusCode.OK, getDeletedItemResponse.HttpStatusCode);
Assert.AreEqual(HttpStatusCode.NoContent, restoreResponse);
Assert.AreEqual(HttpStatusCode.OK, getRestoredItemResponse.HttpStatusCode);
workItemsRequest = null;
recyclebinRequest = null;
}
}

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

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VstsRestApiSamples.ViewModels.Work
{
public class GetTeamSettingsResponse
{
public class Settings : BaseViewModel
{
public Backlogiteration backlogIteration { get; set; }
public string bugsBehavior { get; set; }
public string[] workingDays { get; set; }
public Backlogvisibilities backlogVisibilities { get; set; }
public Defaultiteration defaultIteration { get; set; }
public string defaultIterationMacro { get; set; }
public string url { get; set; }
public _Links _links { get; set; }
}
public class Backlogiteration
{
public string id { get; set; }
public string name { get; set; }
public string path { get; set; }
public string url { get; set; }
}
public class Backlogvisibilities
{
public bool MicrosoftEpicCategory { get; set; }
public bool MicrosoftFeatureCategory { get; set; }
public bool MicrosoftRequirementCategory { get; set; }
}
public class Defaultiteration
{
public string id { get; set; }
public string name { get; set; }
public string path { get; set; }
public string url { get; set; }
}
public class _Links
{
public Self self { get; set; }
public Project project { get; set; }
public Team team { get; set; }
public Teamiterations teamIterations { get; set; }
public Teamfieldvalues teamFieldValues { get; set; }
public Classificationnode[] classificationNode { get; set; }
}
public class Self
{
public string href { get; set; }
}
public class Project
{
public string href { get; set; }
}
public class Team
{
public string href { get; set; }
}
public class Teamiterations
{
public string href { get; set; }
}
public class Teamfieldvalues
{
public string href { get; set; }
}
public class Classificationnode
{
public string href { get; set; }
}
}
}

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

@ -81,6 +81,7 @@
<Compile Include="ViewModels\WorkItemTracking\GetWorkItemsWithLinksAndAttachmentsResponse.cs" />
<Compile Include="ViewModels\WorkItemTracking\WorkItemBatchPost.cs" />
<Compile Include="ViewModels\WorkItemTracking\WorkItemBatchPostResponse.cs" />
<Compile Include="ViewModels\Work\GetTeamSettingsResponse.cs" />
<Compile Include="WorkItemTracking\Attachments.cs" />
<Compile Include="WorkItemTracking\Batch.cs" />
<Compile Include="WorkItemTracking\ClassificationNodes.cs" />
@ -90,8 +91,8 @@
<Compile Include="WorkItemTracking\WIQL.cs" />
<Compile Include="WorkItemTracking\Reporting.cs" />
<Compile Include="WorkItemTracking\WorkItems.cs" />
<Compile Include="Work\ProcessConfiguration\Fields.cs" />
<Compile Include="Work\ProcessConfiguration\Lists.cs" />
<Compile Include="Work\Fields.cs" />
<Compile Include="Work\Lists.cs" />
<Compile Include="WorkItemTracking\Queries.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\BaseViewModel.cs" />
@ -116,6 +117,7 @@
<Compile Include="ViewModels\Work\PickListResponse.cs" />
<Compile Include="ViewModels\Work\PickListPost.cs" />
<Compile Include="ViewModels\Work\PickListPostResponse.cs" />
<Compile Include="Work\TeamSettings.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />

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

@ -3,7 +3,7 @@ using System.Net.Http;
using System.Net.Http.Headers;
using VstsRestApiSamples.ViewModels.Work;
namespace VstsRestApiSamples.Work.ProcessConfiguration
namespace VstsRestApiSamples.Work
{
public class Fields
{

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

@ -3,7 +3,7 @@ using System.Net.Http;
using System.Net.Http.Headers;
using VstsRestApiSamples.ViewModels.Work;
namespace VstsRestApiSamples.Work.ProcessConfiguration
namespace VstsRestApiSamples.Work
{
public class Lists
{

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

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using VstsRestApiSamples.ViewModels.Work;
namespace VstsRestApiSamples.Work
{
public class TeamSettings
{
readonly IConfiguration _configuration;
readonly string _credentials;
public TeamSettings(IConfiguration configuration)
{
_configuration = configuration;
_credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _configuration.PersonalAccessToken)));
}
public GetTeamSettingsResponse.Settings GetTeamsSettings(string project, string team)
{
GetTeamSettingsResponse.Settings viewModel = new GetTeamSettingsResponse.Settings();
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(_configuration.UriString);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);
HttpResponseMessage response = client.GetAsync(project + "/" + team + "/_apis/work/teamsettings?api-version=3.0-preview").Result;
if (response.IsSuccessStatusCode)
{
viewModel = response.Content.ReadAsAsync<GetTeamSettingsResponse.Settings>().Result;
}
viewModel.HttpStatusCode = response.StatusCode;
return viewModel;
}
}
}
}