Exemplo n.º 1
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));
        }