Example #1
0
 public Comparer()
 {
     _diffEngine       = new DiffMatchPatch { Diff_Timeout = 0 };
     var cm            = new ColorMatrix    { Matrix33 = 0.25f };
     _ia               = new ImageAttributes();
     _ia.SetColorMatrix(cm);
     _elementMapper    = new ElementMapper(_diffEngine);
     _conflictResolver = new ConflictResolver<ScrapedElement>();
 }
    void Awake()
    {
        conflictTable = new Dictionary<string, Dictionary<string, int>>();

        conflictTable["Hacker"] = new Dictionary<string, int> { { "Sales", 1 } };
        conflictTable["Sales"] = new Dictionary<string, int> { { "Drone", 1 } };
        conflictTable["Drone"] = new Dictionary<string, int> { { "Hacker", 1 } };

        resolver = new RockPaperScissorsConflictResolver(conflictTable);
    }
Example #3
0
        public void RenameRenameConflictUserMergeTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile          = new MigrationItemStrings(fileName, "b.txt", TestEnvironment, true);
            MigrationItemStrings targetFile          = new MigrationItemStrings(fileName, "c.txt", TestEnvironment, false);
            MigrationItemStrings targetUserMergeFile = new MigrationItemStrings("c.txt", "b.txt", TestEnvironment, false);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            RunAndValidate();

            // 2. source system: a.txt -> b.txt
            int deltaChangeId = SourceAdapter.RenameItem(sourceFile.ServerPath, sourceFile.NewServerPath);

            // 3. target system: a.txt -> c.txt
            TargetAdapter.RenameItem(targetFile.ServerPath, targetFile.NewServerPath);

            // 4. migrate
            Run();
            VerifyHistory(2, 1);

            // 5. resolve conflicts
            // 5.1 User merge actions
            // The user decided to accept other so he reverted the rename change on target system. c.txt -> a.txt
            int miChangeId = TargetAdapter.RenameItem(targetUserMergeFile.ServerPath, targetUserMergeFile.NewServerPath,
                                                      "Rename target items to accept other side's renames **NOMIGRATION**");

            // 5.2 resolve conflicts by VCContentConflictUserMergeChangeAction
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCNameSpaceContentConflictType nameSpaceContentConflict = new VCNameSpaceContentConflictType();

            Assert.IsTrue(nameSpaceContentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be vc namespace content conflict");

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

            dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString());
            dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString());

            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(), string.Format("$/;{0}", deltaChangeId), dataFields);

            // 6. Migration will detect a conflict
            Run(true, true);
            Assert.IsTrue(VerifyContents());

            SourceAdapter.EditFile(sourceFile.NewLocalPath);
            Run(true, true);
            Assert.IsTrue(VerifyContents());
        }
Example #4
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"
            });
        }
Example #5
0
        public void EditEditConflictTakeLocalTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            RunAndValidate();

            // 2. source system: a.txt -> edit
            SourceAdapter.EditFile(sourceFile.LocalPath);

            // 3. target system: a.txt -> edit
            TargetAdapter.EditFile(targetFile.LocalPath);

            // 4. Migration will detect a conflict
            Run();
            VerifyHistory(2, 1);

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

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCContentConflictType contentConflict = new VCContentConflictType();

            Assert.AreEqual(contentConflict.ReferenceName, conflicts[0].ConflictTypeReference.Value.ReferenceName, "It should be vc content conflict");
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/");

            // 6. restart
            Run();

            // 7. validation
            // no remaining conflicts
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // content should not match for one-way sync
                Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated.");

                SourceAdapter.EditFile(sourceFile.LocalPath);
                Run();
                Assert.IsTrue(VerifyContents());
            }
            else
            {
                Assert.IsTrue(VerifyContents());
            }
        }
Example #6
0
        public CodeManager MergeBranches(UserDialog dialog)
        {
            var leftCommand  = LeftCommands.Single();
            var rightCommand = RightCommands.Single();

            var commands = new ConflictResolver().ResolveConflict(dialog, leftCommand, rightCommand);

            dialog.Completed();

            var utility = new Utility();

            return(new CodeManager(utility.ApplyCommands(_code, commands.ToArray())));
        }
Example #7
0
        public void EditEditConflictUserMergeTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, null, TestEnvironment, false);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            RunAndValidate();

            // 2. source system: a.txt -> edit
            int contentConflictChangeset = SourceAdapter.EditFile(sourceFile.LocalPath);

            // 3. target system: a.txt -> edit
            TargetAdapter.EditFile(targetFile.LocalPath);

            // 4. Migration will detect a conflict
            Run();
            VerifyHistory(2, 1);

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

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCContentConflictType contentConflict = new VCContentConflictType();

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

            int deltaChangeId = SourceAdapter.EditFile(sourceFile.LocalPath);
            int miChangeId    = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath);

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

            dataFields.Add(VCContentConflictUserMergeChangeAction.MigrationInstructionChangeId, miChangeId.ToString());
            dataFields.Add(VCContentConflictUserMergeChangeAction.DeltaTableChangeId, deltaChangeId.ToString());

            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictUserMergeChangeAction(),
                                                string.Format("$/;{0}", contentConflictChangeset), dataFields);

            // 6. restart
            Run(true, true);

            // 7. validation
            // no remaining conflicts
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");

            // content should match
            Assert.IsTrue(VerifyContents());
        }
Example #8
0
        public void EditEditMultipleItemsTest()
        {
            // 1. migrate a.txt -> a.txt
            string fileName = "a.txt";
            MigrationItemStrings sourceFile      = new MigrationItemStrings(fileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile      = new MigrationItemStrings(fileName, null, TestEnvironment, false);
            MigrationItemStrings nonConflictFile = new MigrationItemStrings("b.txt", null, TestEnvironment, true);

            SourceAdapter.AddFile(sourceFile.LocalPath);
            SourceAdapter.AddFile(nonConflictFile.LocalPath);
            RunAndValidate();

            // 2. source system: a.txt -> edit
            SourceWorkspace.Get(VersionSpec.Latest, GetOptions.Overwrite);
            TestUtils.EditRandomFile(nonConflictFile.LocalPath);
            SourceWorkspace.PendEdit(nonConflictFile.LocalPath);
            // This will checkin both a.txt and b.txt
            int contentConflictChangeset = SourceAdapter.EditFile(sourceFile.LocalPath);

            // 3. target system: a.txt -> edit
            TargetAdapter.EditFile(targetFile.LocalPath);

            // 4. Migration will detect a conflict
            Run();
            VerifyHistory(2, 1);

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

            Assert.AreEqual(2, conflicts.Count, "There should be 2 conflicts");
            VCContentConflictType contentConflict = new VCContentConflictType();

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

            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/");

            // 6. restart
            Run(true, true);

            // TfsCheckinConflict needs to be resolved manually. Otherwise, this test will loop until time-out.

            // 7. validation
            // no remaining conflicts
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");

            // content should not match
            Assert.IsFalse(VerifyContents(), "The latest content should be different as a.txt is not migrated.");
        }
Example #9
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");
        }
Example #10
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 #11
0
        private void VerifyNoConflicts()
        {
            ConflictResolver  conflictResolver = new ConflictResolver(Configuration);
            List <RTConflict> conflicts        = conflictResolver.GetConflicts();

            if (conflicts.Count > 0)
            {
                foreach (RTConflict conflict in conflicts)
                {
                    Trace.TraceError("Conflict: {0} {1} {2}", conflict.Id, conflict.ConflictedChangeAction, conflict.ConflictDetails);
                }
            }
            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");
        }
Example #12
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));
        }
Example #13
0
        public void VCInvalidPathConflict()
        {
            // Make sure that target mapping path > the source mapping path
            string sourceMapping = TestEnvironment.FirstSourceServerPath;
            string targetMapping = TestEnvironment.FirstTargetServerPath;
            int    lengthDiff    = sourceMapping.Length - targetMapping.Length;

            if (lengthDiff >= 0)
            {
                String path = new String('d', lengthDiff + 1);
                TestEnvironment.Mappings.Clear();
                TestEnvironment.AddMapping(new MappingPair(sourceMapping, TestUtils.URIPathCombine(targetMapping, path), false));
            }

            Assert.IsTrue(TestEnvironment.FirstSourceServerPath.Length < TestEnvironment.FirstTargetServerPath.Length,
                          "This test only works if the source mapping is shorter than the target mapping");

            int fileNameLength = 258 - TestEnvironment.FirstSourceServerPath.Length; // 259 - 1 for '/'

            Assert.IsTrue(fileNameLength > 0, "Source mapping is too long");

            StringBuilder fileNameBuilder = new StringBuilder();

            for (int i = 0; i < fileNameLength; i++)
            {
                fileNameBuilder.Append('a');
            }

            string fileName = fileNameBuilder.ToString();

            MigrationItemStrings file = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings fileInTargetSystem = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            SourceAdapter.AddFile(file.LocalPath);
            try
            {
                Run();
            }
            catch (Exception)
            {
            }

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

            // verify we have edit/edit conflict
            Assert.IsTrue(conflicts.Count == 1, "There should be invalid field value conflict");
            Assert.IsTrue(ConflictConstant.VCInvalidPathConflict.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be an invalid path conflict");
        }
Example #14
0
        public void EstablishContextTest()
        {
            TestEnvironment.WorkFlowType = new WorkFlowType();
            TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Unidirectional;
            TestEnvironment.WorkFlowType.Frequency       = Frequency.ContinuousManual;
            TestEnvironment.WorkFlowType.SyncContext     = SyncContext.Unidirectional;

            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");
        }
Example #15
0
        public static ConflictResolver CreateConflictResolver(OptimizationParameters parameters, ConflictResolveMethod method, Random random, int tournamentParticipants)
        {
            ConflictResolver resolver = method switch
            {
                ConflictResolveMethod.Random => new RandomResolver(random, parameters.ResolveRandomizationProbability),
                ConflictResolveMethod.NearestNeighbor => new NearestNeighborResolver(random, parameters.ResolveRandomizationProbability),
                ConflictResolveMethod.Tournament => new TournamentResolver(random, parameters.ResolveRandomizationProbability),
                ConflictResolveMethod.WarehouseSingleProductFrequency => new WarehouseSingleProductFrequencyResolver(random, parameters.ResolveRandomizationProbability, tournamentParticipants),
                ConflictResolveMethod.WarehousePairwiseProductFrequency => new WarehousePairwiseProductFrequencyResolver(random, parameters.ResolveRandomizationProbability, tournamentParticipants),
                ConflictResolveMethod.WarehouseSigleAndPairwiseResolver => new WarehouseSigleAndPairwiseResolver(random, parameters.ResolveRandomizationProbability, tournamentParticipants),
                _ => throw new ArgumentException("Wrong conflict resolve method name")
            };

            return(resolver);
        }
Example #16
0
        public void AddWorkItemTest()
        {
            // 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 migration result
            VerifySyncResult();
        }
Example #17
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
            });
        }
Example #18
0
        public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, TransportState transportState, string name)
        {
            this.Name = name;
            this.systemConfiguration = systemConfiguration;

            var storageType = systemConfiguration.DefaultFileSystemStorageTypeName;

            if (string.Equals(InMemoryRavenConfiguration.VoronTypeName, storageType, StringComparison.OrdinalIgnoreCase) == false)
            {
                if (Directory.Exists(systemConfiguration.FileSystemDataDirectory) &&
                    Directory.EnumerateFileSystemEntries(systemConfiguration.FileSystemDataDirectory).Any())
                {
                    throw new InvalidOperationException(
                              string.Format(
                                  "We do not allow to run on a storage engine other then Voron, while we are in the early pre-release phase of RavenDB 3.0. You are currently running on {0}",
                                  storageType));
                }

                Trace.WriteLine("Forcing filesystem to run on Voron - pre release behavior only, mind " + Path.GetFileName(Path.GetDirectoryName(systemConfiguration.FileSystemDataDirectory)));
                storageType = InMemoryRavenConfiguration.VoronTypeName;
            }

            storage      = CreateTransactionalStorage(storageType, systemConfiguration);
            search       = new IndexStorage(systemConfiguration.FileSystemIndexStoragePath, systemConfiguration.Settings);
            sigGenerator = new SigGenerator();
            var replicationHiLo = new SynchronizationHiLo(storage);
            var sequenceActions = new SequenceActions(storage);

            this.transportState   = transportState;
            notificationPublisher = new NotificationPublisher(transportState);
            fileLockManager       = new FileLockManager();
            storage.Initialize();
            search.Initialize();
            var uuidGenerator = new UuidGenerator(sequenceActions);

            historian  = new Historian(storage, replicationHiLo, uuidGenerator);
            BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024);
            conflictArtifactManager = new ConflictArtifactManager(storage, search);
            conflictDetector        = new ConflictDetector();
            conflictResolver        = new ConflictResolver();
            synchronizationTask     = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration);
            storageOperationsTask   = new StorageOperationsTask(storage, search, notificationPublisher);
            metricsCounters         = new MetricsCountersManager();

            AppDomain.CurrentDomain.ProcessExit  += ShouldDispose;
            AppDomain.CurrentDomain.DomainUnload += ShouldDispose;
        }
Example #19
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);
        }
Example #20
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
            });
        }
Example #21
0
        public void Link_TwoParentsInHistoryTest()
        {
            // Legend: x->y (y is a parent of x)
            // T1: Source: b->c
            // T2: Sync
            // T3: Target: b->c
            // T4: Source: delete b->c, add b->a
            // T5: Sync

            // add a work item on source side
            int sourceIdA = SourceAdapter.AddWorkItem("Bug", "A", "A");
            int sourceIdB = SourceAdapter.AddWorkItem("Bug", "B", "B");
            int sourceIdC = SourceAdapter.AddWorkItem("Bug", "C", "C");

            RunAndNoValidate();

            // T1
            TfsSourceAdapter.AddParentChildLink(sourceIdC, sourceIdB);
            RunAndNoValidate(true);

            // T4:
            // Source: delete c->b, add a->c ==> b->a->c (a is the child of c)
            TfsSourceAdapter.DeleteParentChildLink(sourceIdC, sourceIdB);
            TfsSourceAdapter.AddParentChildLink(sourceIdA, sourceIdB);

            RunAndNoValidate(true);

            // verify the expected conflict
            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(1, TfsSourceAdapter.GetRelatedLinkCount(sourceIdB));
            Assert.AreEqual(0, TfsSourceAdapter.GetRelatedLinkCount(sourceIdC));

            // Target: delete b->a, add a->b ==> a->b, c->b (a is the child of b)
            int targetId1 = QueryTargetWorkItemID(sourceIdA);
            int targetId2 = QueryTargetWorkItemID(sourceIdB);
            int targetIdC = QueryTargetWorkItemID(sourceIdC);

            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetId1));
            Assert.AreEqual(1, TfsTargetAdapter.GetRelatedLinkCount(targetId2));
            Assert.AreEqual(0, TfsTargetAdapter.GetRelatedLinkCount(targetIdC));
        }
Example #22
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*/
            });
        }
Example #23
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));
        }
Example #24
0
        public void TestWithStringInput()
        {
            string inputString = "(a +40)*num   +\n[(g] * -45x";

            var tokenCategories = new List <KeyValuePair <StringTestCategory, string> >
            {
                new KeyValuePair <StringTestCategory, string>(StringTestCategory.Paren, "[\\(\\)\\[\\]]"),
                new KeyValuePair <StringTestCategory, string>(StringTestCategory.Operator, "[\\*+\\-]"),
                new KeyValuePair <StringTestCategory, string>(StringTestCategory.Number, "0|[1-9][0-9]*"),
                new KeyValuePair <StringTestCategory, string>(StringTestCategory.Variable, "[a-z][a-z]*"),
                new KeyValuePair <StringTestCategory, string>(StringTestCategory.Whitespace, "[ \n][ \n]*")
            };

            var expectedTokens = new List <Token <StringTestCategory> >
            {
                CreateToken(StringTestCategory.Paren, "(", new StringLocation(0), new StringLocation(1)),
                CreateToken(StringTestCategory.Variable, "a", new StringLocation(1), new StringLocation(2)),
                CreateToken(StringTestCategory.Whitespace, " ", new StringLocation(2), new StringLocation(3)),
                CreateToken(StringTestCategory.Operator, "+", new StringLocation(3), new StringLocation(4)),
                CreateToken(StringTestCategory.Number, "40", new StringLocation(4), new StringLocation(6)),
                CreateToken(StringTestCategory.Paren, ")", new StringLocation(6), new StringLocation(7)),
                CreateToken(StringTestCategory.Operator, "*", new StringLocation(7), new StringLocation(8)),
                CreateToken(StringTestCategory.Variable, "num", new StringLocation(8), new StringLocation(11)),
                CreateToken(StringTestCategory.Whitespace, "   ", new StringLocation(11), new StringLocation(14)),
                CreateToken(StringTestCategory.Operator, "+", new StringLocation(14), new StringLocation(15)),
                CreateToken(StringTestCategory.Whitespace, "\n", new StringLocation(15), new StringLocation(16)),
                CreateToken(StringTestCategory.Paren, "[", new StringLocation(16), new StringLocation(17)),
                CreateToken(StringTestCategory.Paren, "(", new StringLocation(17), new StringLocation(18)),
                CreateToken(StringTestCategory.Variable, "g", new StringLocation(18), new StringLocation(19)),
                CreateToken(StringTestCategory.Paren, "]", new StringLocation(19), new StringLocation(20)),
                CreateToken(StringTestCategory.Whitespace, " ", new StringLocation(20), new StringLocation(21)),
                CreateToken(StringTestCategory.Operator, "*", new StringLocation(21), new StringLocation(22)),
                CreateToken(StringTestCategory.Whitespace, " ", new StringLocation(22), new StringLocation(23)),
                CreateToken(StringTestCategory.Operator, "-", new StringLocation(23), new StringLocation(24)),
                CreateToken(StringTestCategory.Number, "45", new StringLocation(24), new StringLocation(26)),
                CreateToken(StringTestCategory.Variable, "x", new StringLocation(26), new StringLocation(27)),
                CreateToken(StringTestCategory.Eof, null, null, null)
            };

            IInputReader inputReader  = new StringInputReader(inputString);
            var          resolver     = new ConflictResolver <StringTestCategory>(StringTestCategory.None);
            var          lexer        = new Lexer <StringTestCategory>(tokenCategories, StringTestCategory.Eof, StringTestCategory.None, resolver.ResolveWithMaxValue);
            var          outputTokens = lexer.Scan(inputReader.Read(), null);

            Assert.IsTrue(outputTokens.SequenceEqual(expectedTokens, new TokenComparer <StringTestCategory>()));
        }
Example #25
0
        public void AddAddConflictTakeLocalTest()
        {
            // initial migration
            MigrationItemStrings file1 = new MigrationItemStrings("1.txt", "1.txt", TestEnvironment, true);

            SourceAdapter.AddFile(file1.LocalPath);
            RunAndValidate();

            // add a same file on both ends
            string fileName = "a.txt";

            MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true);
            MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false);

            int sourceAdd = SourceAdapter.AddFile(sourceFile.LocalPath);

            TargetAdapter.AddFile(targetFile.LocalPath);

            Run();
            VerifyHistory(2, 1);

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

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCContentConflictType contentConflict = new VCContentConflictType();

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

            // resolve the vc content conflict. The chained conflict will be resolved automatically
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeLocalChangeAction(), "$/");

            // continue migration
            Run(true, true);

            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be 0 conflict");

            Assert.IsFalse(VerifyContents(), "Content should be different as we skip the add from source system.");

            SourceAdapter.EditFile(sourceFile.LocalPath);
            Run(true, true);

            Assert.IsTrue(VerifyContents());
        }
Example #26
0
        public void LockedLink_SyncUnlockedFirstThenUpdateLocked()
        {
            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, false);
            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, true);
            RunAndNoValidate(true);

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

            RunAndNoValidate(true);

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

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

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

            Assert.IsTrue(TfsTargetAdapter.IsLinkLocked(mirroredId1, mirroredId2), "migrated link is not locked");
        }
Example #27
0
        public void TwoWay_AddAddConflictTakeOtherTest()
        {
            // continuous manual, bi-directional sync
            TestEnvironment.WorkFlowType = new WorkFlowType();
            TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Bidirectional;
            TestEnvironment.WorkFlowType.Frequency       = Frequency.ContinuousManual;
            TestEnvironment.WorkFlowType.SyncContext     = SyncContext.Disabled;

            // 1. migrate a.txt -> a.txt
            string fileName1    = "a.txt";
            string fileName2    = "b.txt";
            string sameFileName = "same.txt";

            MigrationItemStrings sourceFile1    = new MigrationItemStrings(fileName1, null, TestEnvironment, true);
            MigrationItemStrings sourceSameFile = new MigrationItemStrings(sameFileName, null, TestEnvironment, true);
            MigrationItemStrings targetFile1    = new MigrationItemStrings(fileName2, null, TestEnvironment, false);
            MigrationItemStrings targetSameFile = new MigrationItemStrings(sameFileName, null, TestEnvironment, false);

            SourceAdapter.AddFiles(new string[] { sourceFile1.LocalPath, sourceSameFile.LocalPath });
            TargetAdapter.AddFiles(new string[] { targetFile1.LocalPath, targetSameFile.LocalPath });

            // 4. Migration will detect a conflict
            Run();

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

            Assert.AreEqual(1, conflicts.Count, "There should be 1 conflict");
            VCContentConflictType contentConflict = new VCContentConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be vc content conflict");
            conflictResolver.TryResolveConflict(conflicts[0], new VCContentConflictTakeOtherChangesAction(), conflicts[0].ScopeHint);

            // sync
            Run(true, true);

            // validation
            // no remaining conflicts
            conflicts = conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be NO conflict");

            // content should match
            Assert.IsTrue(VerifyContents(), "The latest content should match.");
        }
Example #28
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");
        }
Example #29
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
            });
        }
        protected SynchronizationWorkItem(string fileName, string sourceServerUrl, ITransactionalStorage storage)
        {
            Storage  = storage;
            FileName = fileName;

            FileAndPagesInformation fileAndPages = null;

            Storage.Batch(accessor => fileAndPages = accessor.GetFile(fileName, 0, 0));
            FileMetadata = fileAndPages.Metadata;
            ServerInfo   = new ServerInfo
            {
                Id            = Storage.Id,
                FileSystemUrl = sourceServerUrl
            };

            conflictDetector = new ConflictDetector();
            conflictResolver = new ConflictResolver(null, null);
        }
Example #31
0
        public void AddWorkItemTest()
        {
            // 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 migration result
            VerifySyncResult();
        }
Example #32
0
        internal static async Task <Solution> RenameAsync(
            RenameLocations locations,
            string newName,
            ImmutableHashSet <ISymbol> nonConflictSymbols = null,
            CancellationToken cancellationToken           = default)
        {
            if (string.IsNullOrEmpty(newName))
            {
                throw new ArgumentException(nameof(newName));
            }

            cancellationToken.ThrowIfCancellationRequested();

            var conflictResolution = await ConflictResolver.ResolveConflictsAsync(
                locations, newName, nonConflictSymbols, cancellationToken).ConfigureAwait(false);

            return(conflictResolution.NewSolution);
        }
		public StandardUnit(ConflictResolver resolver, UnityObject unity)
		{
			Resolver = resolver;
			Health = unity.InitialHealth;
			UnitName = unity.Name;
		}
 public SyncHandler(MobileServiceClient client, ConflictResolver conflictResolver)
     : base(conflictResolver: conflictResolver)
 {
     this.client = client;
     todoTable = App.MobileService.GetSyncTable<TodoItem>();
 }
 public void BeforeEach()
 {
     conflictResolver = Substitute.For<ConflictResolver>();
     unity = Substitute.For<UnityObject>();
 }