public void GetCommentRepresentation_ReturnsCorrectValue()
        {
            RevAndPhaseStatus revAndPhaseStatus = new RevAndPhaseStatus();

            revAndPhaseStatus.Rev = 123;

            ISet <string> phaseStatus = new HashSet <string>();

            phaseStatus.Add("attachments");
            phaseStatus.Add("git commit links");

            revAndPhaseStatus.PhaseStatus = phaseStatus;

            string expected = "123;attachments;git commit links";
            string actual   = revAndPhaseStatus.GetCommentRepresentation();

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        private JsonPatchOperation GetAddHyperlinkWithCommentOperation(IList <WorkItem> targetWorkItems, WorkItemMigrationState state, int sourceId, int targetId, WorkItem sourceWorkItem, ISet <string> enabledPhaseStatuses)
        {
            IList <WorkItemRelation> targetRelations = targetWorkItems.First(a => a.Id == targetId).Relations;

            foreach (WorkItemRelation targetRelation in targetRelations)
            {
                if (RelationHelpers.IsRelationHyperlinkToSourceWorkItem(context, targetRelation, sourceId))
                {
                    string hyperlink = context.WorkItemIdsUris[sourceId];

                    // only store the enabled phase statuses
                    RevAndPhaseStatus newRevAndPhaseStatus = new RevAndPhaseStatus();
                    newRevAndPhaseStatus.Rev         = sourceWorkItem.Rev.Value;
                    newRevAndPhaseStatus.PhaseStatus = enabledPhaseStatuses;
                    state.RevAndPhaseStatus          = newRevAndPhaseStatus;

                    // get the key even if its letter case is different but it matches otherwise
                    string idKeyFromFields = targetRelation.Attributes.GetKeyIgnoringCase(Constants.RelationAttributeId);
                    object attributeId     = targetRelation.Attributes[idKeyFromFields];

                    JsonPatchOperation addHyperlinkWithCommentOperation = MigrationHelpers.GetHyperlinkAddOperation(hyperlink, newRevAndPhaseStatus.GetCommentRepresentation(), attributeId);
                    return(addHyperlinkWithCommentOperation);
                }
            }

            throw new Exception($"Could not find hyperlink to source work item on target work item with id: {targetId}. Expected source work item id: {sourceId}");
        }