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()); }
public void AddAddConflictUserMergeTest() { string fileName = "file.txt"; MigrationItemStrings sourceFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(fileName, fileName, TestEnvironment, false); // Initial sync. Run(); int deltaChangeId = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); // Don't check in extra.txt Run(false, false, false); VerifyHistory(1, 1); // User checkin files to make the system in sync. int miChangeId = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath, "user: delete items on target to resolve add,add conflict **NOMIGRATION**"); // 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"); 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};{1}", "$/", (deltaChangeId - 1).ToString()), dataFields); Run(true, true, false); Assert.IsTrue(VerifyContents()); }
public void AddAddConflictTakeOtherTest() { // 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); 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 VCContentConflictTakeOtherChangesAction(), "$/"); // The user decide to accept other, so he deleted the items on target system TargetAdapter.DeleteItem(targetFile.ServerPath, "Delete source items to accept other side's adds **NOMIGRATION**"); Run(true, true); Assert.IsTrue(VerifyContents()); }
public void PathPeerSnapshotTest() { // Add files // Create a tree structure so that we can test path compression logic. int snapshotChangesetId1 = 0; int peerSnapshotChangesetId1 = 0; for (int i = 0; i < 4; i++) { MigrationItemStrings sourceFile = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(string.Format("source/path1/addFile{0}.txt", i), null, TestEnvironment, false); if (i < 2) { snapshotChangesetId1 = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); peerSnapshotChangesetId1 = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); } else { SourceAdapter.AddFile(sourceFile.LocalPath); } } int snapshotChangesetId2 = 0; int peerSnapshotChangesetId2 = 0; for (int i = 0; i < 4; i++) { MigrationItemStrings sourceFile = new MigrationItemStrings(string.Format("source/path2/addFile{0}.txt", i), null, TestEnvironment, true); MigrationItemStrings targetFile = new MigrationItemStrings(string.Format("source/path2/addFile{0}.txt", i), null, TestEnvironment, false); if (i < 3) { snapshotChangesetId2 = SourceAdapter.AddFile(sourceFile.LocalPath); TargetAdapter.AddFile(targetFile.LocalPath); peerSnapshotChangesetId2 = TargetAdapter.EditFile(targetFile.LocalPath, sourceFile.LocalPath); } else { SourceAdapter.AddFile(sourceFile.LocalPath); } } // We need to map to the sub item level MappingPair rootMapping = TestEnvironment.Mappings[0]; TestEnvironment.Mappings.Clear(); TestEnvironment.Mappings.Add( new MappingPair( rootMapping.SourcePath + "/source/path1", rootMapping.TargetPath + "/source/path1", false, snapshotChangesetId1.ToString(), peerSnapshotChangesetId1.ToString(), null, null, peerSnapshotChangesetId1.ToString(), snapshotChangesetId1.ToString())); TestEnvironment.Mappings.Add( new MappingPair( rootMapping.SourcePath + "/source/path2", rootMapping.TargetPath + "/source/path2", false, snapshotChangesetId2.ToString(), peerSnapshotChangesetId2.ToString(), null, null, peerSnapshotChangesetId2.ToString(), snapshotChangesetId2.ToString())); Run(); MigrationItemStrings newFile = new MigrationItemStrings("source/path1/newFile.txt", null, TestEnvironment, true); SourceAdapter.AddFile(newFile.LocalPath); Run(); Assert.IsTrue(VerifyContents()); }
public void AddAddConflictTakeOtherNoDeleteTest() { // 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 VCContentConflictTakeOtherChangesAction(), "$/"); // The user decided to accept other but forgot deleting the items on target system // start a conflict resolution thread to detect 'future' TfsCheckinConflict and resolve it asynchronously ConflictResolutionWorker resolutionWorker = new ConflictResolutionWorker() { ConflictResolver = conflictResolver, }; resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry() { Conflict = ConflictConstant.TfsCheckinConflict, Resolution = ConflictConstant.TfsCheckinSkipAction, }); resolutionWorker.ConflictResolutionList.Add(new ConflictResolutionEntry() { Conflict = ConflictConstant.TFSZeroCheckinConflict, Resolution = new TFSZeroCheckinSkipAction().ReferenceName, }); resolutionWorker.Start(); // restart the migraiton tool // migration tool will be in a loop until the TfsCheckinConflict gets resolved Run(true, true); Assert.IsTrue(VerifyContents(), "Content should be the same."); SourceAdapter.EditFile(sourceFile.LocalPath); Run(true, true); Trace.WriteLine("Stopping ConflictResolutionWorker"); resolutionWorker.Stop(); Assert.IsTrue(VerifyContents(), "Content should match!"); }