public TfsRestIssue(GetWorkItemResponse w, IEnumerable <string> closedStates) { this.Id = w.id.ToString(); this.Title = w.fields.GetValueOrDefault("System.Title")?.ToString(); this.Description = w.fields.GetValueOrDefault("System.Description")?.ToString(); this.Status = w.fields.GetValueOrDefault("System.State")?.ToString(); this.IsClosed = closedStates.Contains(this.Status, StringComparer.OrdinalIgnoreCase); this.SubmittedDate = AH.ParseDate(w.fields.GetValueOrDefault("System.CreatedDate")?.ToString()) ?? DateTime.MinValue; this.Submitter = w.fields.GetValueOrDefault("System.CreatedBy")?.ToString(); this.Type = w.fields.GetValueOrDefault("System.WorkItemType")?.ToString(); this.Url = w._links.html.href; }
/// <summary> /// Builds a GetWorkItemResponse object /// </summary> public static GetWorkItemResponse CreateGetWorkItemResponse(string workItemName) { GetWorkItemResponse response = new GetWorkItemResponse(); SetProperty(response, "StatusCode", HttpStatusCode.OK); JobExecutionEnvironment jee = new JobExecutionEnvironment(); WorkItem workItem = new WorkItem(workItemName, jee); SetProperty(response, "WorkItem", workItem); return(response); }
public void GetBatchWorkItemTest() { // Setup cmdlet to get a WorkItem by name BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); cmdlet.BatchContext = context; cmdlet.Name = "testWorkItem"; cmdlet.Filter = null; // Build a WorkItem instead of querying the service on a GetWorkItem call YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) => { if (request is GetWorkItemRequest) { GetWorkItemResponse response = BatchTestHelpers.CreateGetWorkItemResponse(cmdlet.Name); Task <object> task = Task <object> .Factory.StartNew(() => { return(response); }); return(task); } return(null); }); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { interceptor }; // Setup the cmdlet to write pipeline output to a list that can be examined later List <PSCloudWorkItem> pipeline = new List <PSCloudWorkItem>(); commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny <PSCloudWorkItem>())).Callback <object>(w => pipeline.Add((PSCloudWorkItem)w)); cmdlet.ExecuteCmdlet(); // Verify that the cmdlet wrote the WorkItem returned from the OM to the pipeline Assert.Equal(1, pipeline.Count); Assert.Equal(cmdlet.Name, pipeline[0].Name); }
/// <summary> /// Builds a GetWorkItemResponse object /// </summary> public static GetWorkItemResponse CreateGetWorkItemResponse(string workItemName) { GetWorkItemResponse response = new GetWorkItemResponse(); SetProperty(response, "StatusCode", HttpStatusCode.OK); JobExecutionEnvironment jee = new JobExecutionEnvironment(); WorkItem workItem = new WorkItem(workItemName, jee); SetProperty(response, "WorkItem", workItem); return response; }