public void Mapping_FieldMapTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetFieldMap); // add a work item on source side int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); RunAndNoValidate(); // verify there's no conflicts raised ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be no conflicts"); // verify sync result excluding expected mismatches WitDiffResult result = GetDiffResult(); VerifySyncResult(result, new List <string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_TITLE, FIELD_DESCRIPTION }); // Title <-> Description int targetId = QueryTargetWorkItemID(workitemId); string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE); string srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION); string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE); string tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION); Assert.AreEqual(srcTitle, tarDesc); Assert.AreEqual(srcDesc, tarTitle); }
public void Mapping_AggregatedFieldTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetAggregatedFieldMap); // 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"); // Title <-> Description int mirroredId = QueryMirroredWorkItemID(workitemId); string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE); string srcRev = SourceAdapter.GetFieldValue(workitemId, "System.Rev"); string tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION); Assert.AreEqual(tarDesc, string.Format(AggregationFormat, srcTitle, srcRev)); }
public void Mapping_UserMapTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetUserValueMap); // add a work item on source side int sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); SourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO); RunAndNoValidate(); // verify there's no conflicts raised ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be no conflicts"); // verify sync result excluding expected mismatches WitDiffResult result = GetDiffResult(); VerifySyncResult(result, new List <string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_ASSIGNEDTO }); // verify the user mapping int targetId = QueryTargetWorkItemID(sourceId); string sourceUser = SourceAdapter.GetFieldValue(sourceId, FIELD_ASSIGNEDTO); string targetUser = TargetAdapter.GetFieldValue(targetId, FIELD_ASSIGNEDTO); Assert.AreEqual(sourceUser, SourceUser); Assert.AreEqual(targetUser, TargetUser); }
public void EditEditConflictIgnoreByFieldChangeTest() { int sourceId; int targetId; EditEditConflictScenario(out sourceId, out targetId); string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE); string srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION); string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE); string tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION); Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict"); Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict"); // verify we have edit/edit conflict List <RTConflict> conflicts = m_conflictResolver.GetConflicts(); Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict"); WITEditEditConflictType contentConflict = new WITEditEditConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be WIT edit/edit conflict"); // resolve the conflict by ignoring conflicts it edits are on different fields bool isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictIgnoreByFieldChangeAction(), "/" + sourceId); Assert.IsFalse(isResolved, "Conflict resolution should fail as both ends edited a same field"); if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight) { isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + targetId); } else { isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + sourceId); } Assert.IsTrue(isResolved, "Conflict resolution should succeed"); // restart the migration tool RunAndNoValidate(true); // verify sync result WitDiffResult result = GetDiffResult(); // ignore Area/Iteration path mismatches due to test environments VerifySyncResult(result, new List <string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH }); srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION); tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION); Assert.AreEqual(srcDesc, SOURCE_R1_DESC); Assert.AreEqual(tarDesc, SOURCE_R1_DESC); }
public void EditEditConflictTakeSourceTest() { int workitemId, mirroredId; EditEditConflictScenario(out workitemId, out mirroredId); string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE); string srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION); string tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE); string tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION); Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict"); Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict"); // verify we have edit/edit conflict List <RTConflict> conflicts = m_conflictResolver.GetConflicts(); Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict"); WITEditEditConflictType contentConflict = new WITEditEditConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be WIT edit/edit conflict"); // resolve the conflict by taking source side changes m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + workitemId); // restart the migration tool RunAndNoValidate(true); // verify sync result WitDiffResult result = GetDiffResult(); // ignore Area/Iteration path mismatches due to test environments VerifySyncResult(result, new List <string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH }); srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION); tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION); Assert.AreEqual(srcDesc, SOURCE_R1_DESC); Assert.AreEqual(tarDesc, SOURCE_R1_DESC); }
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"); }
public void Mapping_UserMapTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(SetUserValueMap); // add a work item on source side string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss")); int workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1"); string srcAssignedTo = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO); SourceUser = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO); RunAndNoValidate(); // verify there's no conflicts raised ConflictResolver conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be no conflicts"); // verify sync result excluding expected mismatches WitDiffResult result = GetDiffResult(); VerifySyncResult(result, new List <string> { FIELD_ITERATION_PATH, FIELD_AREA_PATH, FIELD_ASSIGNEDTO }); // verify the user mapping int mirroredId = QueryMirroredWorkItemID(workitemId); string srcUser = SourceAdapter.GetFieldValue(workitemId, FIELD_ASSIGNEDTO); string tarUser = TargetAdapter.GetFieldValue(mirroredId, FIELD_ASSIGNEDTO); Assert.AreEqual(srcUser, SourceUser); Assert.AreEqual(tarUser, TargetUser); }
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"); }
public void EditEditConflictTakeTargetTest() { int sourceId; int targetId; EditEditConflictScenario(out sourceId, out targetId); string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE); string srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION); string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE); string tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION); Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict"); Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict"); // verify we have edit/edit conflict List <RTConflict> conflicts = m_conflictResolver.GetConflicts(); Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict"); WITEditEditConflictType contentConflict = new WITEditEditConflictType(); Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName), "It should be WIT edit/edit conflict"); // resolve the conflict by taking target side changes 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"); // restart the migration tool RunAndNoValidate(true); srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION); tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION); Assert.AreEqual(TARGET_R1_DESC, tarDesc); if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay) { // VerifySyncResult does not apply to Oneway since we expect differences when we // resolve conflicts by taking Target changes // Source does not get updated on one-way migration Assert.AreEqual(SOURCE_R1_DESC, srcDesc); } else { // 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 }); Assert.AreEqual(TARGET_R1_DESC, srcDesc); } }
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 }); }
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); }