Example #1
0
        public void WorkItemTracking_RecycleBin_GetDeletedItems_Success()
        {
            // arrange
            RecycleBin request = new RecycleBin(_configuration);

            // act
            GetItemsFromRecycleBinResponse.WorkItems response = request.GetDeletedItems(_configuration.Project);

            //assert
            Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode);

            request = null;
        }
Example #2
0
        public GetItemsFromRecycleBinResponse.WorkItems GetDeletedItems(string project)
        {
            GetItemsFromRecycleBinResponse.WorkItems viewModel = new GetItemsFromRecycleBinResponse.WorkItems();

            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 + "/_apis/wit/recyclebin?api-version=3.0-preview").Result;

                if (response.IsSuccessStatusCode)
                {
                    viewModel = response.Content.ReadAsAsync <GetItemsFromRecycleBinResponse.WorkItems>().Result;
                }

                viewModel.HttpStatusCode = response.StatusCode;

                return(viewModel);
            }
        }