Beispiel #1
0
        public void LinkAddAddDeleteLinkTest()
        {
            // add a work item on source side
            int sourceIdA = SourceAdapter.AddWorkItem("Bug", "A", "A");
            int sourceIdB = SourceAdapter.AddWorkItem("Task", "B", "B");
            int sourceIdC = SourceAdapter.AddWorkItem("Scenario", "C", "C");

            RunAndNoValidate();

            // link A-B and A-C
            TfsSourceAdapter.AddRelatedWorkItemLink(sourceIdA, sourceIdB);

            WITChangeAction action = new WITChangeAction()
            {
                Title = "added AB link",
            };

            TfsSourceAdapter.UpdateWorkItem(sourceIdA, action);
            TfsSourceAdapter.UpdateWorkItem(sourceIdB, action);

            TfsSourceAdapter.AddRelatedWorkItemLink(sourceIdA, sourceIdC);

            action = new WITChangeAction()
            {
                Title = "added AC link",
            };
            TfsSourceAdapter.UpdateWorkItem(sourceIdA, action);
            TfsSourceAdapter.UpdateWorkItem(sourceIdC, action);

            // delete A-B link
            TfsSourceAdapter.DeleteRelatedWorkItemLink(sourceIdA, sourceIdB);

            action = new WITChangeAction()
            {
                Title = "deleted AB link",
            };
            TfsSourceAdapter.UpdateWorkItem(sourceIdA, action);
            TfsSourceAdapter.UpdateWorkItem(sourceIdB, action);

            RunAndNoValidate(true);

            // verify no conflicts
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(0, conflicts.Count, "There should be no conflict");

            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(sourceIdA));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(sourceIdB));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(sourceIdC));

            int targetIdA = QueryTargetWorkItemID(sourceIdA);
            int targetIdB = QueryTargetWorkItemID(sourceIdB);
            int targetIdC = QueryTargetWorkItemID(sourceIdC);

            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetIdA));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetIdB));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetIdC));
        }