public void NewWorkItem_Succeeds()
        {
            var context = new EngineContext(client, projectId, projectName, personalAccessToken, logger);
            var sut     = new WorkItemStore(context);

            var wi = sut.NewWorkItem("Task");

            wi.Title = "Brand new";
            var save = sut.SaveChanges(SaveMode.Item, true).Result;

            Assert.NotNull(wi);
            Assert.True(wi.IsNew);
            Assert.Equal(1, save.created);
            Assert.Equal(0, save.updated);
            Assert.Equal(-1, wi.Id.Value);
        }
예제 #2
0
        public async Task NewWorkItem_Succeeds()
        {
            var logger  = Substitute.For <IAggregatorLogger>();
            var client  = Substitute.For <WorkItemTrackingHttpClientBase>(new Uri(CollectionUrl), null);
            var context = new EngineContext(client, projectId, ProjectName, PersonalAccessToken, logger);
            var sut     = new WorkItemStore(context);

            var wi = sut.NewWorkItem("Task");

            wi.Title = "Brand new";
            var save = await sut.SaveChanges(SaveMode.Default, false, CancellationToken.None);

            Assert.NotNull(wi);
            Assert.True(wi.IsNew);
            Assert.Equal(1, save.created);
            Assert.Equal(0, save.updated);
            Assert.Equal(-1, wi.Id.Value);
        }
        public void AddChild_Succeeds()
        {
            var context = new EngineContext(client, projectId, projectName, personalAccessToken, logger);
            var sut     = new WorkItemStore(context);

            var parent = sut.GetWorkItem(1);

            Assert.Equal(2, parent.Relations.Count());

            var newChild = sut.NewWorkItem("Task");

            newChild.Title = "Brand new";
            parent.Relations.AddChild(newChild);

            Assert.NotNull(newChild);
            Assert.True(newChild.IsNew);
            Assert.Equal(-1, newChild.Id.Value);
            Assert.Equal(3, parent.Relations.Count());
        }
예제 #4
0
        public void AddChild_Succeeds()
        {
            var logger     = Substitute.For <IAggregatorLogger>();
            var client     = Substitute.For <WorkItemTrackingHttpClientBase>(new Uri(CollectionUrl), null);
            var context    = new EngineContext(client, projectId, ProjectName, PersonalAccessToken, logger);
            int workItemId = 1;

            client.GetWorkItemAsync(workItemId, expand: WorkItemExpand.All).Returns(new WorkItem
            {
                Id        = workItemId,
                Fields    = new Dictionary <string, object>(),
                Relations = new List <WorkItemRelation>
                {
                    new WorkItemRelation
                    {
                        Rel = "System.LinkTypes.Hierarchy-Forward",
                        Url = $"{workItemsBaseUrl}/42"
                    },
                    new WorkItemRelation
                    {
                        Rel = "System.LinkTypes.Hierarchy-Forward",
                        Url = $"{workItemsBaseUrl}/99"
                    }
                },
            });

            var sut = new WorkItemStore(context);

            var parent = sut.GetWorkItem(1);

            Assert.Equal(2, parent.Relations.Count);

            var newChild = sut.NewWorkItem("Task");

            newChild.Title = "Brand new";
            parent.Relations.AddChild(newChild);

            Assert.NotNull(newChild);
            Assert.True(newChild.IsNew);
            Assert.Equal(-1, newChild.Id.Value);
            Assert.Equal(3, parent.Relations.Count);
        }