Esempio n. 1
0
        //public void CustomizeTargetFilterString(MigrationTestEnvironment env, Configuration config)
        //{
        // Replace target filter string as the default filter string would not
        // work in edit/edit conflict test scenarios
        //FilterItem targetFilterItem = TestEnvironment.GetTargetFilterItem(config.SessionGroup.Sessions.Session[0].Filters.FilterPair[0]);
        //targetFilterItem.FilterString = string.Format("[System.ChangedDate] > '{0}'", TestStartTime);
        //}

        /// Single Edit/Edit conflict
        ///
        /// 1. Source (S) and Target (T) are in sync
        ///
        /// Both ends have changes
        /// 2. Source revisions: A1 -> B
        /// 3. Target revisions: A2
        ///
        /// 4. Start Bi-directional migration (1st round)
        /// 5. Tool generates 1 edit/edit conflict with chained conflicts
        ///    Raise edit/edit conflicts for S:A1 and T:A2
        ///    Raise chained conflicts for S:B
        ///
        private void EditEditConflictScenario(out int sourceId, out int targetId)
        {
            // test edit/edit conflit in bi-directional work flow
            //TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString);

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

            // sync
            RunAndNoValidate();

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

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

            // update work items on both sides
            WITChangeAction sourceAction = new WITChangeAction();
            WITChangeAction targetAction = new WITChangeAction();

            targetId = QueryTargetWorkItemID(sourceId);

            sourceAction.Description = SOURCE_R1_DESC; // S:A1
            SourceAdapter.UpdateWorkItem(sourceId, sourceAction);
            sourceAction.Title = SOURCE_R2_TITLE;      // S:B
            SourceAdapter.UpdateWorkItem(sourceId, sourceAction);

            targetAction.Description = TARGET_R1_DESC; // T:A2
            TargetAdapter.UpdateWorkItem(targetId, targetAction);

            // sync again
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);
        }
Esempio n. 2
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");
        }
Esempio n. 3
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
            });
        }
Esempio n. 4
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*/
            });
        }
Esempio n. 5
0
        public void HistoryNotFound_ResolveByUpdateConvHistory()
        {
            this.TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget);
            this.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");

            WITChangeAction action = new WITChangeAction();

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

            action          = new WITChangeAction();
            action.Priority = "2";
            SourceAdapter.UpdateWorkItem(workitemId, action);

            // sync again and expect conflict
            RunAndNoValidate();

            // check conflicts
            m_conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There is no active conflict");
            Assert.IsTrue(ConflictConstant.WitHistoryNotFoundConflictType.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "The first active conflict is not a history-not-found conflict");

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

            dataFields.Add("Source Item Id", workitemId.ToString());
            dataFields.Add("Source Revisions", "1");
            dataFields.Add("Target Item Id", "17526" /*"@@PLACE_HOLDER@@"*/);
            dataFields.Add("Target Revisions", "1");
            m_conflictResolver.TryResolveConflict(conflicts[0],
                                                  ConflictConstant.HistoryNotFoundUpdateConversionHistoryAction,
                                                  conflicts[0].ScopeHint, dataFields);


            RunAndNoValidate(true);
            m_conflictResolver = new ConflictResolver(Configuration);
            conflicts          = m_conflictResolver.GetConflicts();
            Assert.IsTrue(conflicts.Count == 0, "There is unresolved conflict");
        }
Esempio n. 6
0
        /// Single Edit/Edit conflict
        ///
        /// 1. Source (S) and Target (T) are in sync
        ///
        /// Both ends have changes
        /// 2. Source revisions: A1 -> B
        /// 3. Target revisions: A2
        ///
        /// 4. Start Bi-directional migration (1st round)
        /// 5. Tool generates 1 edit/edit conflict with chained conflicts
        ///    Raise edit/edit conflicts for S:A1 and T:A2
        ///    Raise chained conflicts for S:B
        ///
        private void EditEditConflictScenario(out int workitemId, out int mirroredId)
        {
            // test edit/edit conflit in bi-directional work flow
            TestEnvironment.WorkFlowType = new WorkFlowType();
            TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Bidirectional;
            TestEnvironment.WorkFlowType.Frequency       = Frequency.ContinuousManual;
            TestEnvironment.WorkFlowType.SyncContext     = SyncContext.Disabled;
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString);

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

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

            // sync
            RunAndNoValidate();

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

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

            // update work items on both sides
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            mirroredId = QueryMirroredWorkItemID(workitemId);

            action1.Description = SOURCE_R1_DESC; // S:A1
            SourceAdapter.UpdateWorkItem(workitemId, action1);
            action1.Title = SOURCE_R2_TITLE;      // S:B
            SourceAdapter.UpdateWorkItem(workitemId, action1);
            action2.Description = TARGET_R1_DESC; // T:A2
            TargetAdapter.UpdateWorkItem(mirroredId, action2);

            //WITChangeAction action3 = new WITChangeAction();
            //action3.Title = TestContext.TestName + " title T:D"; // T:D
            //TargetAdapter.UpdateWorkItem(mirroredId, action3);

            // sync again
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);
        }
Esempio n. 7
0
        public void Mapping_ConditionalHybridValueMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetConditionalHybridPriorityValueMap);

            // 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, ConditionalValueMapDescription);

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "2";
            SourceAdapter.UpdateWorkItem(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 excluding expected mismatches
            WitDiffResult result = GetDiffResult();

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

            // P1 == P2
            int    mirroredId = QueryMirroredWorkItemID(workitemId);
            string srcPri     = SourceAdapter.GetFieldValue(workitemId, FIELD_PRIORITY);
            string tarPri     = TargetAdapter.GetFieldValue(mirroredId, FIELD_PRIORITY);

            Assert.AreEqual(srcPri, "2");
            Assert.AreEqual(tarPri, "3");
        }
Esempio n. 8
0
        public void Mapping_ConditionalWildcardValueMapTest()
        {
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync);
            TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetConditionalWildcardPriorityValueMap);

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

            WITChangeAction action1 = new WITChangeAction();

            action1.Priority = "2";
            SourceAdapter.UpdateWorkItem(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 excluding expected mismatches
            WitDiffResult result = GetDiffResult();

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

            // P1 == P2
            int    targetId       = QueryTargetWorkItemID(workitemId);
            string sourcePriority = SourceAdapter.GetFieldValue(workitemId, FIELD_PRIORITY);
            string targetPriority = TargetAdapter.GetFieldValue(targetId, FIELD_PRIORITY);

            Assert.AreEqual(sourcePriority, "2");
            Assert.AreEqual(targetPriority, "3");
        }
Esempio n. 9
0
        public void EditEditConflictTakeTargetAfterMoreDeltaFromSourceTest()
        {
            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");

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

            Assert.AreEqual(1, conflicts.Count, "There should be one edit/edit conflict");

            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

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

            // ---- start *5.5
            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("update work items on both sides");
            Trace.WriteLine("---------------------------------");
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            const string SourceLastDesc = "New Description 5.5.1";

            action1.Description = SourceLastDesc;
            SourceAdapter.UpdateWorkItem(sourceId, action1);

            const string TargetLastTitle = "New Title 5.5.2";

            action2.Title = TargetLastTitle;
            TargetAdapter.UpdateWorkItem(targetId, action2);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);

            // ----- end *5.5

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("resolve the conflict by taking target side changes");
            Trace.WriteLine("---------------------------------");
            bool isResolved = false;

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

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            RunAndNoValidate(true);

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

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // For one-way we took the target changes, but those changes should not migrate back to source
                Assert.AreEqual(SourceLastDesc, srcDesc);
                Assert.AreEqual(SourceLastDesc, tarDesc);

                Assert.IsTrue(srcTitle.EndsWith(SOURCE_R2_TITLE));
                Assert.IsTrue(tarTitle.EndsWith(SOURCE_R2_TITLE));
            }
            else
            {
                Assert.AreEqual(TARGET_R1_DESC, srcDesc);
                Assert.AreEqual(TARGET_R1_DESC, tarDesc);
                Assert.IsTrue(srcTitle.EndsWith(TargetLastTitle));
                Assert.IsTrue(tarTitle.EndsWith(TargetLastTitle));
            }

            // 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
            });
        }
Esempio n. 10
0
        public void EditEditConflictTakeTargetAfterMoreDeltaFromSourceTest()
        {
            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");

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("verify we have edit/edit conflict");
            Trace.WriteLine("---------------------------------");
            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");

            #region *5.5
            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("update work items on both sides");
            Trace.WriteLine("---------------------------------");
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            const string SourceLastDesc  = "New Desc 5.5.1";
            const string TargetLastTitle = "New Title 5.5.2";
            action1.Description = SourceLastDesc;
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            action2.Title = TargetLastTitle;
            TargetAdapter.UpdateWorkItem(mirroredId, action2);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);

            #endregion

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("resolve the conflict by taking target side changes");
            Trace.WriteLine("---------------------------------");
            m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + workitemId);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            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(TARGET_R1_DESC, srcDesc);
            Assert.AreEqual(TARGET_R1_DESC, tarDesc);

            srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            Assert.AreEqual(TargetLastTitle, srcTitle);
            Assert.AreEqual(TargetLastTitle, tarTitle);
        }
Esempio n. 11
0
        public void LinkScenarioExperienceTest()
        {
            const int ExperienceCount = 10;
            // On Left add 1 Scenario and a bunch of Experiences

            int sourceScenarioId = SourceAdapter.AddWorkItem("Scenario", "scenario title", "source scenario description");

            Console.WriteLine("Source Scenario ID = {0}", sourceScenarioId);

            int[] sourceExperienceIDs = new int[ExperienceCount];
            int[] targetExperienceIDs = new int[ExperienceCount];

            for (int index = 0; index < ExperienceCount; index++)
            {
                string title = string.Format("Experience {0}", index);
                sourceExperienceIDs[index] = SourceAdapter.AddWorkItem("Experience", title, title);
            }

            // sync
            RunAndNoValidate();

            // get the migrated target ID
            int targetScenarioId = QueryTargetWorkItemID(sourceScenarioId);

            Console.WriteLine("Target Scenario ID = {0}", targetScenarioId);

            // Modify some field of the scenario: this should create a revision of the work item that has no link changes to get migrated
            WITChangeAction sourceAction = new WITChangeAction()
            {
                History = "Adding scenario-experience links on the source side",
            };

            SourceAdapter.UpdateWorkItem(sourceScenarioId, sourceAction);

            // Link source scenario to all the experiences
            for (int index = 0; index < ExperienceCount; index++)
            {
                TfsSourceAdapter.AddScenarioExperienceLink(sourceScenarioId, sourceExperienceIDs[index]);
            }

            // Modify the history again forcing the above links to get migrated
            WITChangeAction sourceAction2 = new WITChangeAction()
            {
                AssignedTo = "billbar",
            };

            SourceAdapter.UpdateWorkItem(sourceScenarioId, sourceAction2);

            for (int index = 0; index < ExperienceCount; index++)
            {
                Console.WriteLine("Getting mirrored TargetWorkItemID for target experience: " + sourceExperienceIDs[index].ToString());
                targetExperienceIDs[index] = QueryTargetWorkItemID(sourceExperienceIDs[index]);
                Console.WriteLine("Mirrored TargetWorkItemID: " + targetExperienceIDs[index].ToString());
            }

            /*
             * // on target modify field of the mirrored Ids of each of the Experience
             * // This should cause them to get sync'd back to the source side
             * WITChangeAction targetAction = new WITChangeAction()
             * {
             *  History = "Touch the target experience work item",
             * };
             * foreach (int targetExperienceID in targetExperienceIDs)
             * {
             *  TargetAdapter.UpdateWorkItem(targetExperienceID, targetAction);
             * }
             */

            // sync
            RunAndNoValidate(true);

            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(ExperienceCount, TfsSourceAdapter.GetRelatedLinkCount(sourceScenarioId));
            Assert.AreEqual(ExperienceCount, TfsSourceAdapter.GetRelatedLinkCount(targetScenarioId));
        }