Example #1
0
        public void Link_AddRelatedLinkTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            string title1      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId1 = SourceAdapter.AddWorkItem("Bug", title1, "description1");

            string title2      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId2 = SourceAdapter.AddWorkItem("Bug", title1, "description2");

            RunAndNoValidate();

            TfsSourceAdapter.AddRelatedWorkItemLink(workitemId1, workitemId2);
            RunAndNoValidate(true);

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

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

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            int mirroredId = QueryMirroredWorkItemID(workitemId1);

            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredId));
        }
Example #2
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));
        }
Example #3
0
        public void Link_DeleteRelatedLinkFromBothSideTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_SetBidirectionalNoContextSync);

            // add a work item on source side
            string title1      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId1 = SourceAdapter.AddWorkItem("Bug", title1, "description1");

            string title2      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId2 = SourceAdapter.AddWorkItem("Bug", title1, "description2");

            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetTargetFilterString);

            RunAndNoValidate();

            int mirroredId1 = QueryMirroredWorkItemID(workitemId1);
            int mirroredId2 = QueryMirroredWorkItemID(workitemId2);

            // source: add a related link
            TfsSourceAdapter.AddRelatedWorkItemLink(workitemId1, workitemId2);
            RunAndNoValidate(true);
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredId1), "RelatedLink count on target system is wrong");

            // source: delete the link
            TfsSourceAdapter.DeleteRelatedWorkItemLink(workitemId1, workitemId2);

            // target: delete the same link
            TfsTargetAdapter.DeleteRelatedWorkItemLink(mirroredId1, mirroredId2);
            RunAndNoValidate(true);

            // now both sides shouldn't have a link
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(workitemId1), "RelatedLink count on source system is wrong");
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(workitemId1), "RelatedLink count on target system is wrong");


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

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

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Example #4
0
        public void Link_DeleteRelatedLinkFromTargetTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            int sourceId1 = TfsSourceAdapter.AddWorkItem("Bug", "title1", "description1");

            int sourceId2 = TfsSourceAdapter.AddWorkItem("Bug", "title2", "description2");

            RunAndNoValidate();

            int targetId1 = QueryTargetWorkItemID(sourceId1);

            Console.WriteLine(String.Format("SourceId1: {0}, TargetId1: {1}", sourceId1, targetId1));
            int targetId2 = QueryTargetWorkItemID(sourceId2);

            Console.WriteLine(String.Format("SourceId2: {0}, TargetId2: {1}", sourceId2, targetId2));

            // source: add a related link
            TfsSourceAdapter.AddRelatedWorkItemLink(sourceId1, sourceId2);
            RunAndNoValidate(true);

            // source side should have one link
            int sourceLinkCount = TfsSourceAdapter.GetRelatedLinkCount(sourceId1);

            Assert.AreEqual(1, sourceLinkCount, "RelatedLink count on source system should be 1");

            int targetLinkCount = TfsTargetAdapter.GetRelatedLinkCount(targetId1);

            Assert.AreEqual(1, targetLinkCount, "RelatedLink count on target system should be 1");

            // target: delete the mirrored link
            TfsTargetAdapter.DeleteRelatedWorkItemLink(targetId1, targetId2);
            RunAndNoValidate(true);

            // now target side shouldn't have any links
            targetLinkCount = TfsTargetAdapter.GetRelatedLinkCount(targetId1);
            Assert.AreEqual(0, targetLinkCount, "RelatedLink count on target system should be 0");

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

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

            sourceLinkCount = TfsSourceAdapter.GetRelatedLinkCount(sourceId1);

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // source side should still have the original link
                Assert.AreEqual(1, sourceLinkCount, "source side link should still exist");
            }
            else
            {
                // now source side shouldn't have any links
                Assert.AreEqual(0, sourceLinkCount, "source side link should be deleted");

                // verify sync result
                WitDiffResult result = GetDiffResult();

                // ignore Area/Iteration path mismatches
                VerifySyncResult(result, new List <string> {
                    FIELD_ITERATION_PATH, FIELD_AREA_PATH
                });
            }
        }
Example #5
0
        public void Link_MultiAddDeleteRelatedLinkTest()
        {
            for (int i = 0; i < 7; ++i)
            {
                // add a work item on source side
                string title = "title " + i.ToString();
                int    id    = SourceAdapter.AddWorkItem("Bug", title, "description1");
                SourceWorkItemIdList[i] = id;
            }

            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[0]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[2]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[3]);

            RunAndNoValidate();

            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[0]));
            Assert.AreEqual(3, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[1]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[2]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[3]));

            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[0]);
            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[2]);
            TfsSourceAdapter.DeleteRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[3]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[4]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[5]);
            TfsSourceAdapter.AddRelatedWorkItemLink(SourceWorkItemIdList[1], SourceWorkItemIdList[6]);
            RunAndNoValidate(true);

            RunAndNoValidate(true);

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

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

            //// verify sync result
            //WitDiffResult result = GetDiffResult();

            //// ignore Area/Iteration path mismatches
            //VerifySyncResult(result, new List<string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH });

            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[0]));
            Assert.AreEqual(3, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[1]));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[2]));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[3]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[4]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[5]));
            Assert.AreEqual(1, TfsSourceAdapter.GetRelatedLinkCount(SourceWorkItemIdList[6]));

            int[] targetWorkItemIds = new int[SourceWorkItemIdList.Count];
            for (int i = 0; i < SourceWorkItemIdList.Count; ++i)
            {
                targetWorkItemIds[i] = QueryTargetWorkItemID(SourceWorkItemIdList[i]);
            }

            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[0]));
            Assert.AreEqual(3, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[1]));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[2]));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[3]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[4]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[5]));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetWorkItemIds[6]));
        }