public void UpdateAttachment(int workItemId, WITAttachmentChangeAction action) { // find the entity OAdEntity entity = GetEntityByDBId(workItemId); // mark entity to be editable CQWrapper.EditEntity(m_session, entity, "Modify"); foreach (WITAttachment attachment in action.Attachments) { if (attachment.ActionType == AttachmentChangeActionType.Add) { AddAttachment(entity, attachment.FileName, attachment.Comment); } else if (attachment.ActionType == AttachmentChangeActionType.Delete) { throw new NotImplementedException("DeleteAttachment is not supported yet"); } // Update attachment comment else if (attachment.ActionType == AttachmentChangeActionType.Edit) { throw new NotImplementedException("EditAttachment is not supported yet"); } } SaveWorkItem(entity); }
public void Attachment_IncrementalAttachmentTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget); // add a work item on source side int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); // add the first attachment WITAttachmentChangeAction action1 = new WITAttachmentChangeAction(); action1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1")); SourceAdapter.UpdateAttachment(workitemId, action1); // sync RunAndNoValidate(); // add the second attachment WITAttachmentChangeAction action2 = new WITAttachmentChangeAction(); action2.AddAttachment(new WITAttachment("attachment2.txt", "comment 2")); SourceAdapter.UpdateAttachment(workitemId, action2); // sync again 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 migration result VerifySyncResult(); }
public void Attachment_BasicTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget); TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_DisableContextSync); // add a work item on source side int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); // update link comment WITAttachmentChangeAction action1 = new WITAttachmentChangeAction(); action1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1")); SourceAdapter.UpdateAttachment(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 WitDiffResult result = GetDiffResult(); // ignore Area/Iteration path mismatches VerifySyncResult(result, new List <string> { "System.IterationPath", "System.AreaPath" }); }
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" }); }
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"); }
public void UpdateAttachment(int workItemId, WITAttachmentChangeAction action) { string condition = String.Format("[System.Id] = {0}", workItemId); WITUtil util = new WITUtil(WorkItemStore, TeamProjectName, condition, string.Empty); WorkItem wi = util.WorkItems[0]; wi.Open(); foreach (WITAttachment attachment in action.Attachments) { if (attachment.ActionType == AttachmentChangeActionType.Add) { wi.Attachments.Add(CreateAttachment(attachment.FileName, attachment.Comment)); } else if (attachment.ActionType == AttachmentChangeActionType.Delete) { Attachment item = FindAttachment(attachment.FileName, attachment.Comment, wi.Attachments); if (item != null) { wi.Attachments.Remove(item); } } // Update attachment comment else if (attachment.ActionType == AttachmentChangeActionType.Edit) { throw new NotImplementedException("EditAttachment is not supported yet"); //Attachment item = FindAttachment(attachment.FileName, attachment.Comment, wi.Attachments); //if (item != null) //{ // TODO: Update comment // Comment is read-only //item.Comment = attachment.Comment; //} } } ArrayList invalidFields = wi.Validate(); if (invalidFields.Count != 0) { Assert.Fail("Failed to update work item: {0}", wi.Id); } wi.Save(); }
public void Attachment_AttachmentTest() { TestEnvironment.CustomActions += new MigrationTestEnvironment.Customize(ConfigCustomizer.CustomActions_EnableBypassRulesOnTarget); // add a work item on source side int workitemId = SourceAdapter.AddWorkItem("Bug", "title", "description1"); WITAttachmentChangeAction action1 = new WITAttachmentChangeAction(); action1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1")); SourceAdapter.UpdateAttachment(workitemId, action1); RunAndNoValidate(); // verify there's no conflicts raised VerifyNoConflicts(); // verify migration result VerifySyncResult(); }
public void Attachment_AttachmentTest() { 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(); action1.AddAttachment(new WITAttachment("attachment1.txt", "comment 1")); SourceAdapter.UpdateAttachment(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 migration result VerifySyncResult(); }