Пример #1
0
        public void Mapping_FieldMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetFieldMap);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            RunAndNoValidate();

            // 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 excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH,
                FIELD_TITLE, FIELD_DESCRIPTION
            });

            // Title <-> Description
            int    targetId = QueryTargetWorkItemID(workitemId);
            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreEqual(srcTitle, tarDesc);
            Assert.AreEqual(srcDesc, tarTitle);
        }
Пример #2
0
        public void Link_AddParentTest()
        {
            // add a work item on source side
            int workitemId1 = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            int workitemId2 = SourceAdapter.AddWorkItem("Bug", "title2", "description2");

            Console.WriteLine(String.Format("Source work item Ids: Parent: {0}, Child: {1}", workitemId1, workitemId2));

            RunAndNoValidate();

            TfsSourceAdapter.AddParentChildLink(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 mirroredId1 = QueryTargetWorkItemID(workitemId1);
            int mirroredId2 = QueryTargetWorkItemID(workitemId2);

            Console.WriteLine(String.Format("Target work item Ids: Parent: {0}, Child: {1}", mirroredId1, mirroredId2));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(mirroredId1));
            Assert.AreEqual(false, TfsTargetAdapter.IsLinkLocked(mirroredId1, mirroredId2));
        }
Пример #3
0
        public void Mapping_MissingStateReasonFieldMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetMissingStateReasonFieldMap);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            RunAndNoValidate();

            // 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 excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH,
                FIELD_TITLE, FIELD_DESCRIPTION
            });
        }
Пример #4
0
        public void Attachment_BasicTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            // update link comment

            WITAttachmentChangeAction action1 = new WITAttachmentChangeAction();

            action1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1"));
            SourceAdapter.UpdateAttachment(workitemId, action1);

            RunAndNoValidate();

            // 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> {
                "System.IterationPath", "System.AreaPath"
            });
        }
Пример #5
0
        public void BasicWorkItemTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));

            int workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1");

            RunAndNoValidate();

            // 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> {
                "System.IterationPath", "System.AreaPath"
            });
        }
Пример #6
0
        public void Mapping_UserMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetUserValueMap);

            // add a work item on source side
            int sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            SourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO);

            RunAndNoValidate();

            // 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 excluding expected mismatches
            WitDiffResult result = GetDiffResult();

            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_ASSIGNEDTO
            });

            // verify the user mapping
            int    targetId   = QueryTargetWorkItemID(sourceId);
            string sourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO);
            string targetUser = TargetAdapter.GetFieldValue(targetId, FIELD_ASSIGNEDTO);

            Assert.AreEqual(sourceUser, SourceUser);
            Assert.AreEqual(targetUser, TargetUser);
        }
Пример #7
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));
        }
Пример #8
0
        public void BasicWorkItemTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            RunAndNoValidate();

            // 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();

            // Get migrated workitem ID.  This will Fail if it cannot find it.
            QueryTargetWorkItemID(workitemId);

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                "System.IterationPath", "System.AreaPath"
            });
        }
Пример #9
0
        internal WitDiffResult GetDiffResult()
        {
            ServerDiffEngine diff            = new ServerDiffEngine(Guid.Empty, false, true, SessionTypeEnum.WorkItemTracking);
            WITDiffComparer  witDiffComparer = new WITDiffComparer(diff, true);

            diff.RegisterDiffComparer(witDiffComparer);

            // Add additional fields for which different values should not cause a failure because
            // the tests are configured such that these will be different
            HashSet <string> fieldsToIgnore = new HashSet <string>();

            fieldsToIgnore.Add("System.AreaPath");
            fieldsToIgnore.Add("System.IterationPath");

            bool          allContentsMatch = witDiffComparer.VerifyContentsMatch(null, null, fieldsToIgnore, fieldsToIgnore);
            WitDiffResult result           = witDiffComparer.DiffResult;

            Trace.TraceInformation("==============  Result ===================");
            Trace.TraceInformation("Work Item count: {0}", result.WorkItemCount);
            Trace.TraceInformation("#Attachments mismatch: {0}", result.AttachmentMismatchCount);
            Trace.TraceInformation("#Links mismatch: {0}", result.LinkMismatchCount);
            Trace.TraceInformation("#Content mismatch: {0}", result.ContentMismatchCount);
            Trace.TraceInformation("#Missing WorkItems: {0}", result.MissingWorkItemCount);
            Trace.TraceInformation("All contents match: {0}", allContentsMatch);

            return(result);
        }
Пример #10
0
        public void LockedLink_BasicSyncTest()
        {
            // add a work item on source side
            int workitemId1 = SourceAdapter.AddWorkItem("Bug", "parent", "description1");
            int workitemId2 = SourceAdapter.AddWorkItem("Bug", "child", "description2");

            RunAndNoValidate();

            TfsSourceAdapter.AddParentChildLink(workitemId1, workitemId2, 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
            });

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

            Assert.IsTrue(TfsTargetAdapter.IsLinkLocked(mirroredId1, mirroredId2), "migrated link is not locked");
        }
Пример #11
0
        public void WITPagingTest()
        {
            // Note the size of page is 50
            int pageSize = 50;

            // add 49 work items (page size - 1)
            BatchAddWorkItems(pageSize - 1);
            RunAndNoValidate(false);

            // add 50 work items
            BatchAddWorkItems(pageSize);
            RunAndNoValidate(true);

            // add 51 work items
            BatchAddWorkItems(pageSize + 1);
            RunAndNoValidate(true);

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

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                "System.IterationPath", "System.AreaPath"
            });
        }
Пример #12
0
        public void EditEditConflictIgnoreByFieldChangeTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by ignoring conflicts it edits are on different fields
            bool isResolved = m_conflictResolver.TryResolveConflict(conflicts[0],
                                                                    new WITEditEditConflictIgnoreByFieldChangeAction(), "/" + sourceId);

            Assert.IsFalse(isResolved, "Conflict resolution should fail as both ends edited a same field");

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");

            // restart the migration tool
            RunAndNoValidate(true);

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

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

            srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Пример #13
0
        internal override WitDiffResult VerifySyncResult()
        {
            WitDiffResult result = GetDiffResult();

            Assert.AreEqual(0, result.AttachmentMismatchCount, "# of attachments mismatch");
            Assert.AreEqual(0, result.LinkMismatchCount, "# of links mismatch");
            Assert.AreEqual(0, result.ContentMismatchCount, "content mismatch");

            return(result);
        }
Пример #14
0
        internal override WitDiffResult VerifySyncResult()
        {
            WitDiffResult result = GetDiffResult();

            Assert.AreEqual(0, result.AttachmentMismatchCount, "# of attachments mismatch");
            Assert.AreEqual(0, result.LinkMismatchCount, "# of links mismatch");
            Assert.AreEqual(0, result.ContentMismatchCount, "content mismatch");
            //Assert.AreEqual(0, result.MissingWorkItemCount, "WorkItems were not migrated");
            //Assert.IsTrue(result.AllContentsMatch, "Contents do not match");
            return(result);
        }
Пример #15
0
        public void AttachmentAddAddDeleteTest()
        {
            // add a work item on source side
            int sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            // update link comment

            WITAttachmentChangeAction add1 = new WITAttachmentChangeAction();

            add1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1"));
            SourceAdapter.UpdateAttachment(sourceId, add1);

            WITAttachmentChangeAction add2 = new WITAttachmentChangeAction();

            add2.AddAttachment(new WITAttachment("attachment2.txt", "comment 2"));
            SourceAdapter.UpdateAttachment(sourceId, add2);

            RunAndNoValidate(true);

            WITAttachmentChangeAction delete2 = new WITAttachmentChangeAction();

            delete2.DeleteAttachment(new WITAttachment("attachment2.txt", null));
            SourceAdapter.UpdateAttachment(sourceId, delete2);

            WITAttachmentChangeAction add3 = new WITAttachmentChangeAction();

            add3.AddAttachment(new WITAttachment("attachment3.txt", "comment 2"));
            SourceAdapter.UpdateAttachment(sourceId, add3);

            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");

            int targetId    = QueryTargetWorkItemID(sourceId);
            int sourceCount = TfsSourceAdapter.GetAttachmentCount(sourceId);
            int targetCount = TfsTargetAdapter.GetAttachmentCount(targetId);

            Assert.AreEqual(2, sourceCount, "source should have 2 attachments");
            Assert.AreEqual(2, targetCount, "target should have 2 attachments");

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

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                "System.IterationPath", "System.AreaPath"
            });
        }
Пример #16
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
            });
        }
Пример #17
0
        public void Attachment_DeleteTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);

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

            WITAttachmentChangeAction action1     = new WITAttachmentChangeAction();
            WITAttachment             attachment1 = new WITAttachment("attachment1.txt", "comment 1");

            action1.AddAttachment(attachment1);
            SourceAdapter.UpdateAttachment(workitemId, action1);

            RunAndNoValidate();

            // delete the attachment
            WITAttachmentChangeAction action2 = new WITAttachmentChangeAction();

            action2.DeleteAttachment(attachment1);
            SourceAdapter.UpdateAttachment(workitemId, action2);

            WITChangeAction action3 = new WITChangeAction();

            action3.Description = "Description change by action 3";
            SourceAdapter.UpdateWorkItem(workitemId, action3);

            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> {
                "System.IterationPath", "System.AreaPath"
            });

            // TODO: Remove the following verification once ServerDiff supports attachment count diffing.
            int mirroredId = QueryMirroredWorkItemID(workitemId);

            Assert.AreEqual(TfsSourceAdapter.GetAttachmentCount(workitemId),
                            TfsTargetAdapter.GetAttachmentCount(mirroredId), "Attachment counts should be same");
        }
Пример #18
0
        public void Link_DeleteHyperLinkTest()
        {
            // TODO:  Figure out why this tests fail against TFS 2008 but works in TFS 2010

            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

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

            // add a link
            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);
            WITLink             link1   = new WITLink("link1");

            action1.AddLink(link1);
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate();

            // 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");

            // delete the link
            action1 = new WITLinkChangeAction(LinkChangeActionType.Delete);
            action1.AddLink(link1);
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate(true);

            // verify there's no conflicts raised
            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
            });

            // TODO: Remove the following verification once ServerDiff supports link diffing.
            int mirroredId = QueryTargetWorkItemID(workitemId);

            Assert.AreEqual(TfsSourceAdapter.GetHyperLinkCount(workitemId),
                            TfsTargetAdapter.GetHyperLinkCount(mirroredId));
        }
Пример #19
0
        public void Link_CyclicLinkBidirectionalTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_SetBidirectionalNoContextSync);

            Link_CyclicLinkScenarioTwoWay();

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

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Пример #20
0
        public void InvalidFieldConflictUseFieldMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetInvalidFieldMap);

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

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "3";
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            // sync
            RunAndNoValidate();

            // verify we have InvalidField conflict
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There is no active conflict");
            Assert.IsTrue(ConflictConstant.InvalidFieldConflictType.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "The first active conflict is not a WIT invalid field conflict");

            Dictionary <string, string> dataFields = new Dictionary <string, string>();

            dataFields.Add("MapFrom", InvalidFieldRefName);
            dataFields.Add("MapTo", FIELD_DESCRIPTION);
            dataFields.Add(Constants.DATAKEY_UPDATED_CONFIGURATION_ID, "1");
            m_conflictResolver.TryResolveConflict(conflicts[0],
                                                  ConflictConstant.InvalidFieldConflictUseFieldMapAction,
                                                  conflicts[0].ScopeHint, dataFields);

            // restart the migration tool
            RunAndNoValidate(true);

            conflicts = m_conflictResolver.GetConflicts();
            Assert.IsTrue(conflicts.Count == 0, "There should be no conflict");

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

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Пример #21
0
        public void Link_BasicTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

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

            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action1.AddLink(new WITLink("link1"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate();

            // 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");

            // validate the conversion history entries
            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                string sourceItemId       = workitemId.ToString();
                var    migrationItemQuery =
                    from mi in context.RTMigrationItemSet
                    where mi.ItemId.Equals(sourceItemId) && mi.ItemVersion.Equals("Link")
                    select mi;
                Assert.AreEqual(migrationItemQuery.Count(), 1);

                long miId          = migrationItemQuery.First().Id;
                var  itemPairQuery =
                    from p in context.RTItemRevisionPairSet
                    where p.LeftMigrationItemId == miId || p.RightMigrationItemId == miId
                    select p;
                Assert.AreEqual(itemPairQuery.Count(), 1);
            }

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

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Пример #22
0
        public void Link_MultipleTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

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

            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action1.AddLink(new WITLink("link1"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate();

            WITLinkChangeAction action2 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action2.AddLink(new WITLink("link2"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action2);

            RunAndNoValidate(true);

            WITLinkChangeAction action3 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action3.AddLink(new WITLink("link3"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action3);

            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(workitemId);

            Assert.AreEqual(TfsTargetAdapter.GetHyperLinkCount(mirroredId), 3);
        }
Пример #23
0
        public void InvalidFieldValueConflict_ResolveByDroppingFieldTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetInvalidFieldValueMap);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableBypassRulesOnTarget);

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

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "1";
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            // sync
            RunAndNoValidate();

            // verify we have InvalidField conflict
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There is no active conflict");
            Assert.IsTrue(ConflictConstant.InvalidFieldValueConflictType.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "The first active conflict is not a WIT invalid field value conflict");

            Dictionary <string, string> dataFields = new Dictionary <string, string>();

            dataFields.Add("InvalidFieldReferenceName", FIELD_PRIORITY);
            dataFields.Add(Constants.DATAKEY_UPDATED_CONFIGURATION_ID, "1");

            var rslvRslt = m_conflictResolver.TryResolveConflict(
                conflicts[0], new Guid("3C8FE19D-3D02-4a19-BC5A-77640B0F5904"), "/", dataFields);

            Assert.IsTrue(rslvRslt, "Conflict resolution failed");

            // sync again
            RunAndNoValidate(true);

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

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH, "Priority"                                         /*FIELD_PRIORITY teyang: verification uses field name rather than ref name*/
            });
        }
Пример #24
0
        private void DeleteHyperLinkScenario()
        {
            // add a work item on source side
            string title      = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss"));
            int    workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1");

            // add a link
            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);
            WITLink             link1   = new WITLink("link1");

            action1.AddLink(link1);
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate();

            // 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");

            // delete the link
            action1 = new WITLinkChangeAction(LinkChangeActionType.Delete);
            action1.AddLink(link1);
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            RunAndNoValidate(true);

            // verify there's no conflicts raised
            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
            });

            // TODO: Remove the following verification once ServerDiff supports link diffing.
            int mirroredId = QueryMirroredWorkItemID(workitemId);

            Assert.AreEqual(TfsSourceAdapter.GetHyperLinkCount(workitemId),
                            TfsTargetAdapter.GetHyperLinkCount(mirroredId));
        }
Пример #25
0
        public void LockedLink_RemoveLockAndDeleteLinkSyncTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

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

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

            RunAndNoValidate();

            TfsSourceAdapter.AddParentChildLink(workitemId1, workitemId2, 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");


            TfsSourceAdapter.UpdateLinkLockOption(workitemId1, workitemId2, false);
            TfsSourceAdapter.DeleteParentChildLink(workitemId1, workitemId2);
            RunAndNoValidate(true);

            // verify there's a conflict raised
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");

            conflictResolver.TryResolveConflict(conflicts[0],
                                                ConflictConstant.TFSModifyLockedWorkItemLinkConflict_ResolveByForceDeleteAction,
                                                conflicts[0].ScopeHint);

            RunAndNoValidate(true);

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

            // ignore Area/Iteration path mismatches
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Пример #26
0
        public void Link_UpdateTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);

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

            string location             = "link1";
            WITLinkChangeAction action1 = new WITLinkChangeAction(LinkChangeActionType.Add);

            action1.AddLink(new WITLink(location, "comment1"));
            SourceAdapter.UpdateWorkItemLink(workitemId, action1);

            // update link comment
            string newComment           = "new comment 2";
            WITLinkChangeAction action2 = new WITLinkChangeAction(LinkChangeActionType.Edit);

            action2.AddLink(new WITLink(location, newComment));
            SourceAdapter.UpdateWorkItemLink(workitemId, action2);

            RunAndNoValidate();

            // 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
            });

            // Title <-> Description
            int mirroredId = QueryTargetWorkItemID(workitemId);

            Assert.AreEqual(TfsTargetAdapter.GetHyperLinkCount(mirroredId), 1);
            WITLink tarLink = TargetAdapter.GetHyperLink(mirroredId, location);

            Assert.AreEqual(tarLink.Comment, newComment);
        }
Пример #27
0
        public void InvalidFieldConflictUseFieldMapCaseInsensitiveTest()
        {
            // Same as InvalidFieldConflictUseFieldMappTest except testing
            // case-sensitivity of the resolution rule

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

            // add a work item on source side
            int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1");

            // sync
            RunAndNoValidate();

            // verify we have InvalidField conflict
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There is no active conflict");
            Assert.IsTrue(ConflictConstant.InvalidFieldConflictType.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "The first active conflict is not a WIT invalid field conflict");

            Dictionary <string, string> dataFields = new Dictionary <string, string>();

            dataFields.Add("MapFrom", InvalidFieldRefName.ToUpper()); // use upper case
            dataFields.Add("MapTo", FIELD_DESCRIPTION.ToLower());     // use lower case
            dataFields.Add(Constants.DATAKEY_UPDATED_CONFIGURATION_ID, "1");
            m_conflictResolver.TryResolveConflict(conflicts[0],
                                                  ConflictConstant.InvalidFieldConflictUseFieldMapAction,
                                                  conflicts[0].ScopeHint, dataFields);

            // restart the migration tool
            RunAndNoValidate(true);

            conflicts = m_conflictResolver.GetConflicts();
            Assert.IsTrue(conflicts.Count == 0, "There should be no conflict");

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

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Пример #28
0
        public void EditEditConflictTakeSourceTest()
        {
            int workitemId, mirroredId;

            EditEditConflictScenario(out workitemId, out mirroredId);

            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by taking source side changes
            m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + workitemId);

            // restart the migration tool
            RunAndNoValidate(true);

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

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

            srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Пример #29
0
        internal void VerifySyncResult(WitDiffResult diffResult, List <string> ignoreFieldNames)
        {
            Assert.AreEqual(0, diffResult.AttachmentMismatchCount, "# of attachments mismatch");
            Assert.AreEqual(0, diffResult.LinkMismatchCount, "# of links mismatch");

            foreach (WitDiffPair pair in diffResult.WitDiffPairs)
            {
                int fieldMismatchCount = 0;
                foreach (WitDiffField f in pair.DiffFields)
                {
                    if (Contains(ignoreFieldNames, f.FieldName))
                    {
                        Trace.TraceInformation("Ignore field mismatch: {0}", f.FieldName);
                        fieldMismatchCount++;
                    }
                }
                Assert.AreEqual(pair.DiffFields.Count, fieldMismatchCount);
            }

            Trace.TraceInformation("Content match!");
        }
Пример #30
0
        public void LockedLink_SkipDeleteLinkSyncTest()
        {
            // add a work item on source side
            int workitemId1 = SourceAdapter.AddWorkItem("Bug", "parent", "description1");
            int workitemId2 = SourceAdapter.AddWorkItem("Bug", "child", "description2");

            RunAndNoValidate();

            TfsSourceAdapter.AddParentChildLink(workitemId1, workitemId2, 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");

            TfsSourceAdapter.UpdateLinkLockOption(workitemId1, workitemId2, false);
            TfsSourceAdapter.DeleteParentChildLink(workitemId1, workitemId2);
            RunAndNoValidate(true);

            // verify there's a conflict raised
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");

            conflictResolver.TryResolveConflict(conflicts[0],
                                                new SkipConflictedActionResolutionAction().ReferenceName,
                                                conflicts[0].ScopeHint);

            RunAndNoValidate(true);

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

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

            // TODO: Why does TwoWayRight have only one link mismatch, but the others have 2?
            Assert.AreEqual(2, result.LinkMismatchCount);
        }