Exemple #1
0
        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 AcceptanceCriteriaWindow(WorkItem workItem) : base("[#" + workItem.Id + "] " + workItem.Title() + " - " + "Acceptance Criteria")
        {
            X           = 0;
            Y           = 2; // Leave one row for the toplevel menu
            Width       = Dim.Fill();
            Height      = Dim.Fill();
            ColorScheme = Program.ColorScheme;

            Add(new TextView
            {
                Width       = Dim.Fill(),
                Height      = Dim.Fill(),
                ColorScheme = Program.ColorScheme,
                Text        = workItem.AcceptanceCriteria(),//.WordWrap(Console.WindowWidth - 2),
                ReadOnly    = true
            });
        }
        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);
        }
Exemple #5
0
        public static IEnumerable <View> For(WorkItem item)
        {
            var details = new[]
            {
                new
                {
                    Label   = "Fields (" + item.Fields.Count + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <FieldsWindow>())
                },
                new
                {
                    Label   = "Description (" + item.Description().LineCount() + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <DescriptionWindow>())
                },
                new
                {
                    Label   = "Acceptance Criteria (" + item.AcceptanceCriteria().LineCount() + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <AcceptanceCriteriaWindow>())
                },
                new
                {
                    Label   = "Q&C (" + item.QuestionsAndClarifications().LineCount() + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <QuestionsClarificationsWindow>())
                },
                new
                {
                    Label   = "Comments (" + item.CommentCount() + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <CommentsWindow>())
                },
                new
                {
                    Label   = "Links (" + item.Attachments().Count() + ")",
                    Clicked = new Action(() => Application.Top.SetFocus <AttachmentsWindow>())
                },
                new
                {
                    Label   = "Web",
                    Clicked = new Action(() =>
                    {
                        var url = new Uri(Program.Settings.Url, $"{item.TeamProject()}/_workitems/edit/{item.Id}/");
                        Process.Start(url.ToString());
                    })
                },
            };

            var x = 1;

            foreach (var b in details)
            {
                var result = new Button(x, 0, b.Label)
                {
                    Clicked = b.Clicked
                };
                x = result.Frame.Right + 1;
                yield return(result);
            }

            // hack
            yield return(new Button(-1, -1, "X")
            {
                Clicked = async() =>
                {
                    Application.Top.SetFocus <AttachmentsWindow>();

                    var attachmentsWindow = Application.Top.View <AttachmentsWindow>();
                    var selectedIndex = attachmentsWindow.View <ListView>().SelectedItem;
                    if (selectedIndex == 0)
                    {
                        return;
                    }

                    var attachment = item.Attachments().ElementAt(selectedIndex - 1);
                    var id = attachment.Url.Split('/').Last();
                    var stream = await Program.Api.GetClient <WorkItemTrackingHttpClient>().GetAttachmentContentAsync(new Guid(id));

                    byte[] bytes;
                    using (var ms = new MemoryStream())
                    {
                        stream.CopyTo(ms);
                        bytes = ms.ToArray();
                    }

                    var path = Path.Combine(Path.GetTempPath(), attachment.Attributes["name"].ToString());
                    File.WriteAllBytes(path, bytes);
                    Process.Start(path);
                }
            });
        }