//public void CustomizeTargetFilterString(MigrationTestEnvironment env, Configuration config) //{ // Replace target filter string as the default filter string would not // work in edit/edit conflict test scenarios //FilterItem targetFilterItem = TestEnvironment.GetTargetFilterItem(config.SessionGroup.Sessions.Session[0].Filters.FilterPair[0]); //targetFilterItem.FilterString = string.Format("[System.ChangedDate] > '{0}'", TestStartTime); //} /// Single Edit/Edit conflict /// /// 1. Source (S) and Target (T) are in sync /// /// Both ends have changes /// 2. Source revisions: A1 -> B /// 3. Target revisions: A2 /// /// 4. Start Bi-directional migration (1st round) /// 5. Tool generates 1 edit/edit conflict with chained conflicts /// Raise edit/edit conflicts for S:A1 and T:A2 /// Raise chained conflicts for S:B /// private void EditEditConflictScenario(out int sourceId, out int targetId) { // test edit/edit conflit in bi-directional work flow //TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString); // add a work item on source side sourceId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); // sync RunAndNoValidate(); // verify there's no conflicts raised m_conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = m_conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be no conflicts"); // update work items on both sides WITChangeAction sourceAction = new WITChangeAction(); WITChangeAction targetAction = new WITChangeAction(); targetId = QueryTargetWorkItemID(sourceId); sourceAction.Description = SOURCE_R1_DESC; // S:A1 SourceAdapter.UpdateWorkItem(sourceId, sourceAction); sourceAction.Title = SOURCE_R2_TITLE; // S:B SourceAdapter.UpdateWorkItem(sourceId, sourceAction); targetAction.Description = TARGET_R1_DESC; // T:A2 TargetAdapter.UpdateWorkItem(targetId, targetAction); // sync again // 1 edit/edit conflict with chained conflicts RunAndNoValidate(true); }
/// Single Edit/Edit conflict /// /// 1. Source (S) and Target (T) are in sync /// /// Both ends have changes /// 2. Source revisions: A1 -> B /// 3. Target revisions: A2 /// /// 4. Start Bi-directional migration (1st round) /// 5. Tool generates 1 edit/edit conflict with chained conflicts /// Raise edit/edit conflicts for S:A1 and T:A2 /// Raise chained conflicts for S:B /// private void EditEditConflictScenario(out int workitemId, out int mirroredId) { // test edit/edit conflit in bi-directional work flow TestEnvironment.WorkFlowType = new WorkFlowType(); TestEnvironment.WorkFlowType.DirectionOfFlow = DirectionOfFlow.Bidirectional; TestEnvironment.WorkFlowType.Frequency = Frequency.ContinuousManual; TestEnvironment.WorkFlowType.SyncContext = SyncContext.Disabled; TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(CustomizeTargetFilterString); // add a work item on source side string title = string.Format("{0} {1}", TestContext.TestName, DateTime.Now.ToString("HH'_'mm'_'ss")); workitemId = SourceAdapter.AddWorkItem("Bug", title, "description1"); // sync RunAndNoValidate(); // verify there's no conflicts raised m_conflictResolver = new ConflictResolver(Configuration); List <RTConflict> conflicts = m_conflictResolver.GetConflicts(); Assert.AreEqual(0, conflicts.Count, "There should be no conflicts"); // update work items on both sides WITChangeAction action1 = new WITChangeAction(); WITChangeAction action2 = new WITChangeAction(); mirroredId = QueryMirroredWorkItemID(workitemId); action1.Description = SOURCE_R1_DESC; // S:A1 SourceAdapter.UpdateWorkItem(workitemId, action1); action1.Title = SOURCE_R2_TITLE; // S:B SourceAdapter.UpdateWorkItem(workitemId, action1); action2.Description = TARGET_R1_DESC; // T:A2 TargetAdapter.UpdateWorkItem(mirroredId, action2); //WITChangeAction action3 = new WITChangeAction(); //action3.Title = TestContext.TestName + " title T:D"; // T:D //TargetAdapter.UpdateWorkItem(mirroredId, action3); // sync again // 1 edit/edit conflict with chained conflicts RunAndNoValidate(true); }
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); }