public DevOpsWorkItem Map(WorkItem parentWorkItem, List <WorkItem> childWorkItems) { switch (parentWorkItem.WorkItemType()) { case "Product Backlog Item": return(new DevOpsProductBacklogItem { Id = parentWorkItem.Id ?? 0, Title = parentWorkItem.Title(), State = parentWorkItem.State(), AssignedTo = parentWorkItem.AssignedTo(), AcceptanceCriteria = parentWorkItem.AcceptanceCriteria(), Description = parentWorkItem.Description(), Tasks = childWorkItems?.Select(_mapWorkItemToTaskCommand.Map).Where(t => t != null).ToList() ?? new List <DevOpsTask>() }); case "Bug": return(new DevOpsBug { Id = parentWorkItem.Id ?? 0, Title = parentWorkItem.Title(), State = parentWorkItem.State(), AssignedTo = parentWorkItem.AssignedTo(), AcceptanceCriteria = parentWorkItem.AcceptanceCriteria(), ReproSteps = parentWorkItem.ReproSteps(), SystemInfo = parentWorkItem.SystemInfo(), Tasks = childWorkItems?.Select(_mapWorkItemToTaskCommand.Map).Where(t => t != null).ToList() ?? new List <DevOpsTask>() }); default: return(null); } }
public void ReturnsDevOpsTaskWhen_ValidTaskProvided(WorkItem workItem) { workItem.Fields[AzureDevOpsFields.WorkItemType] = "Task"; var result = _subject.Map(workItem); Assert.AreEqual(workItem.Id, result.Id); Assert.AreEqual(workItem.Title(), result.Title); Assert.AreEqual(workItem.Description(), result.Description); Assert.AreEqual(workItem.State(), result.State); Assert.AreEqual(workItem.AssignedTo(), result.AssignedTo); Assert.AreEqual(workItem.RemainingWork(), result.RemainingWork); }
public DevOpsTask Map(WorkItem childWorkItem) { if (childWorkItem.WorkItemType() != "Task") { return(null); } return(new DevOpsTask { Id = childWorkItem.Id ?? 0, Title = childWorkItem.Title(), Description = childWorkItem.Description(), AssignedTo = childWorkItem.AssignedTo(), State = childWorkItem.State(), RemainingWork = childWorkItem.RemainingWork() }); }
public void GeneratesDevOpsProductBacklogItem(WorkItem workItem, List <WorkItem> childWorkItems) { workItem.Fields[AzureDevOpsFields.WorkItemType] = "Product Backlog Item"; childWorkItems.ForEach(t => t.Fields[AzureDevOpsFields.WorkItemType] = "Task"); var result = _subject.Map(workItem, childWorkItems); _mapWorkItemToTaskCommand.Verify(s => s.Map(It.IsAny <WorkItem>()), Times.Exactly(childWorkItems.Count)); Assert.IsTrue(typeof(DevOpsProductBacklogItem) == result.GetType()); var castResult = (DevOpsProductBacklogItem)result; Assert.AreEqual(workItem.Id, castResult.Id); Assert.AreEqual(workItem.Title(), castResult.Title); Assert.AreEqual(workItem.State(), castResult.State); Assert.AreEqual(workItem.AssignedTo(), castResult.AssignedTo); Assert.AreEqual(workItem.Description(), castResult.Description); Assert.AreEqual(childWorkItems.Count, castResult.Tasks.Count); }
public void ReturnsValidItemsWhen_NullChildItems(WorkItem workItem) { workItem.Fields[AzureDevOpsFields.WorkItemType] = "Bug"; var result = _subject.Map(workItem, null); _mapWorkItemToTaskCommand.Verify(s => s.Map(It.IsAny <WorkItem>()), Times.Exactly(0)); Assert.IsTrue(typeof(DevOpsBug) == result.GetType()); var castResult = (DevOpsBug)result; Assert.AreEqual(workItem.Id, castResult.Id); Assert.AreEqual(workItem.Title(), castResult.Title); Assert.AreEqual(workItem.State(), castResult.State); Assert.AreEqual(workItem.AssignedTo(), castResult.AssignedTo); Assert.AreEqual(workItem.AcceptanceCriteria(), castResult.AcceptanceCriteria); Assert.AreEqual(workItem.ReproSteps(), castResult.ReproSteps); Assert.AreEqual(workItem.SystemInfo(), castResult.SystemInfo); Assert.AreEqual(0, castResult.Tasks.Count); }
public void GeneratesDevOpsBug(WorkItem workItem, List <WorkItem> childWorkItems) { workItem.Fields[AzureDevOpsFields.WorkItemType] = "Bug"; childWorkItems.ForEach(t => t.Fields[AzureDevOpsFields.WorkItemType] = "Task"); var result = _subject.Map(workItem, childWorkItems); _mapWorkItemToTaskCommand.Verify(s => s.Map(It.IsAny <WorkItem>()), Times.Exactly(childWorkItems.Count)); Assert.IsTrue(typeof(DevOpsBug) == result.GetType()); var castResult = (DevOpsBug)result; Assert.AreEqual(workItem.Id, castResult.Id); Assert.AreEqual(workItem.Title(), castResult.Title); Assert.AreEqual(workItem.State(), castResult.State); Assert.AreEqual(workItem.AssignedTo(), castResult.AssignedTo); Assert.AreEqual(workItem.AcceptanceCriteria(), castResult.AcceptanceCriteria); Assert.AreEqual(workItem.ReproSteps(), castResult.ReproSteps); Assert.AreEqual(workItem.SystemInfo(), castResult.SystemInfo); Assert.AreEqual(childWorkItems.Count, castResult.Tasks.Count); }