Ejemplo n.º 1
0
        /// <summary>
        /// Returns all of the work items that are a result of a hierarchical query
        /// </summary>
        /// <param name="query">The query to execute</param>
        /// <returns>The list of WorkItemData that contains the results</returns>
        private List <WorkItemData> GetHierarchicalResults(Query query)
        {
            List <WorkItemData> temp = new List <WorkItemData>();

            //Returns the links related to this particular query - this will return
            //all of the work item ID's (source and target) returned by the qurey, but
            //no actual work items
            WorkItemLinkInfo[] links = query.RunLinkQuery();

            //Get the actual work items associated with the source and target ID's from the
            //query
            Dictionary <int, WorkItem> resultWIs = null;
            List <WorkItemData>        workItems = new List <WorkItemData>();

            //At this point, resultWIs have all of the work items in the query
            if (links != null)
            {
                resultWIs = GetWorkItemsById(links, query);
            }

            for (int wiIndex = 0; wiIndex < links.Length; wiIndex++)
            {
                WorkItemLinkInfo wiInfo = links[wiIndex];

                workItems.Add(new WorkItemData()
                {
                    ID = wiInfo.TargetId, ParentID = wiInfo.SourceId, WI = resultWIs[wiInfo.TargetId]
                });
            }

            return(workItems);
        }
        /// <summary>
        /// Sets up a hierarchical query to return some work items.
        /// </summary>
        /// <param name="links">Set of work item id tuples to return from the link query. The first is the source id, the second is the target id.</param>
        /// <param name="workItems">The work items to return.</param>
        /// <param name="fieldNames">The list of field names to be returned by the query.</param>
        private void SetupHierarchicalQuery(Tuple <int, int>[] links, ITfsWorkItem[] workItems, string[] fieldNames)
        {
            WorkItemLinkInfo[] wilis = new WorkItemLinkInfo[links.Length];
            for (int i = 0; i < links.Length; i++)
            {
                wilis[i] = new WorkItemLinkInfo()
                {
                    SourceId = links[i].Item1, TargetId = links[i].Item2
                };
            }

            IList <ITfsFieldDefinition> displayFields = new List <ITfsFieldDefinition>();

            foreach (string name in fieldNames)
            {
                Mock <ITfsFieldDefinition> mockFd = new Mock <ITfsFieldDefinition>();
                mockFd.Setup(fd => fd.ReferenceName).Returns(name);
                displayFields.Add(mockFd.Object);
            }

            this.mockQuery.Setup(q => q.RunLinkQuery(It.IsAny <CancellationToken>())).Returns(wilis);
            this.mockQuery.Setup(q => q.DisplayFieldList).Returns(displayFields);
            this.mockQuery.Setup(q => q.WorkItemStore.Query(It.IsAny <int[]>(), It.IsAny <string>())).Returns(new List <ITfsWorkItem>(workItems));
            this.mockQueryFactory.Setup(qf => qf.CreateTfsQuery(It.IsAny <string>(), It.IsAny <IDictionary>())).Returns(this.mockQuery.Object);
        }
Ejemplo n.º 3
0
 public WorkItemLinkInfoDetails(WorkItemLinkInfo linkInfo, WorkItem sourceWorkItem,
     WorkItem targetWorkItem,WorkItemLinkType linkType)
 {
     this.LinkInfo = linkInfo;
     this.SourceWorkItem = sourceWorkItem;
     this.TargetWorkItem = targetWorkItem;
     this.LinkType = linkType;
 }
Ejemplo n.º 4
0
 public WorkItemLinkInfoDetails(WorkItemLinkInfo linkInfo, WorkItem sourceWorkItem,
                                WorkItem targetWorkItem, WorkItemLinkType linkType)
 {
     this.LinkInfo       = linkInfo;
     this.SourceWorkItem = sourceWorkItem;
     this.TargetWorkItem = targetWorkItem;
     this.LinkType       = linkType;
 }
Ejemplo n.º 5
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, int sourceId, int targetId)
     : base(targetId, linkTypeEnd)
 {
     if (sourceId == targetId)
     {
         throw new ArgumentException($"Parameter {nameof(sourceId)} cannot be the same as {nameof(targetId)}.");
     }
     LinkInfo = new WorkItemLinkInfo(sourceId, targetId, linkTypeEnd);
 }
        internal static WorkItemLinkInfoWrapper GetInstance()
        {
            WorkItemLinkInfo real = default(WorkItemLinkInfo);

            RealInstanceFactory(ref real);
            WorkItemLinkInfoWrapper instance = WorkItemLinkInfoWrapper.GetWrapper(real);

            InstanceFactory(ref instance);
            return(instance);
        }
Ejemplo n.º 7
0
        internal static WorkItemLinkInfoWrapper GetInstance()
        {
            var real = new WorkItemLinkInfo();

            RealInstanceFactory(ref real);
            var instance = (WorkItemLinkInfoWrapper)WorkItemLinkInfoWrapper.GetWrapper(real);

            InstanceFactory(ref instance);
            if (instance == null)
            {
                Assert.Inconclusive("Could not Create Test Instance");
            }
            return(instance);
        }
Ejemplo n.º 8
0
        private static void CreateDependencyText(TextBlock txtBlock, ref string ids, WorkItemLinkInfo link, WorkItem teamIterationWorkItem)
        {
            if (link.LinkTypeId == -3)
            {
                var relWi = GetWiFromBoard(link.TargetId);
                if (relWi == null)
                {
                    relWi = _tfs.GetWorkItem(link.TargetId.ToString());
                }
                if (teamIterationWorkItem.AreaId != relWi.AreaId) // only if dependency is from another team
                {
                    txtBlock.Inlines.Add(new System.Windows.Documents.Run
                    {
                        Background = Brushes.Blue,
                        Foreground = Brushes.White,
                        FontFamily = new FontFamily("Comic Sans"),
                        Text       = System.Environment.NewLine + link.TargetId + " |" + relWi.Type.Name + "| " + relWi.IterationPath
                    });
                    txtBlock.Background = Brushes.Pink;
                    ids += link.TargetId + " ";

                    if (!_dependencies.ContainsKey(teamIterationWorkItem.AreaPath))
                    {
                        _dependencies.Add(teamIterationWorkItem.AreaPath, new List <KeyValuePair <string, string> >());
                    }
                    _dependencies[teamIterationWorkItem.AreaPath].Add(new KeyValuePair <string, string>(relWi.AreaPath, link.TargetId.ToString()));
                }
            }
            if (link.LinkTypeId == 3 && LoadSuccesors)
            {
                var relWi = GetWiFromBoard(link.TargetId);
                if (relWi == null)
                {
                    relWi = _tfs.GetWorkItem(link.TargetId.ToString());
                }
                if (teamIterationWorkItem.AreaId != relWi.AreaId) // only if dependency is from another team
                {
                    txtBlock.Inlines.Add(new System.Windows.Documents.Run
                    {
                        Background = Brushes.MidnightBlue,
                        Foreground = Brushes.Pink,
                        FontFamily = new FontFamily("Comic Sans"),
                        Text       = System.Environment.NewLine + link.TargetId + " |" + relWi.Type.Name + "| " + relWi.IterationPath
                    });
                    txtBlock.Background = Brushes.Pink;
                    ids += link.TargetId + " ";
                }
            }
        }
Ejemplo n.º 9
0
        private static bool IsValidLinkInfo(WorkItemLinkInfo linkInfo, WorkItemLinkType linkType)
        {
            if (linkType == null)
            {
                return(false);
            }

            // If the link id in the link info is 0 we handle a root item --> ann accepted sceanrio
            if (linkInfo.LinkTypeId == 0)
            {
                return(true);
            }
            // If the link id from the link info matches the forward end link id of the given link type than we have a link that fits
            if (linkInfo.LinkTypeId == linkType.ForwardEnd.Id)
            {
                return(true);
            }
            // IN all other cases the link type being configured does not fit to the link info being returned by a query
            return(false);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 从WorkItemLinkInfo对象中获取WorkItemLinkInfoDetails。
        /// </summary>
        public WorkItemLinkInfoDetails GetDetailsFromWorkItemLinkInfo(WorkItemLinkInfo linkInfo)
        {
            if (linkInfo == null)
            {
                throw new ArgumentNullException("linkInfo");
            }

            if (this.LinkTypes.ContainsKey(linkInfo.LinkTypeId))
            {
                WorkItemLinkInfoDetails details = new WorkItemLinkInfoDetails(
                    linkInfo,
                    this.WorkItemStore.GetWorkItem(linkInfo.SourceId),
                    this.WorkItemStore.GetWorkItem(linkInfo.TargetId),
                    this.LinkTypes[linkInfo.LinkTypeId]);
                return(details);
            }
            else
            {
                throw new ApplicationException("Cannot find WorkItemLinkType!");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Runs a tree query.
        /// </summary>
        /// <param name="query">The query to execute.</param>
        /// <param name="cancellationToken">Used to cancel the operation.</param>
        /// <returns>A tree of work items.</returns>
        private static WorkItemTree RunTreeQuery(ITfsQuery query, CancellationToken cancellationToken)
        {
            WorkItemTree ans = new WorkItemTree();

            WorkItemLinkInfo[] wilis = query.RunLinkQuery(cancellationToken);
            int[] ids = new int[wilis.Length];
            for (int i = 0; i < ids.Length; i++)
            {
                ids[i] = wilis[i].TargetId;
            }

            string workItemQueryString     = QueryUtilities.ConvertTreeQueryToQueryForItem(query);
            IList <ITfsWorkItem> workItems = query.WorkItemStore.Query(ids.Distinct().ToArray(), workItemQueryString);

            for (int i = 0; i < wilis.Length; i++)
            {
                WorkItemLinkInfo wili = wilis[i];
                ITfsWorkItem     wi   = workItems.Select(item => item).Where(item => item.Id == wili.TargetId).Single();
                if (wili.SourceId <= 0)
                {
                    ans.RootNodes.Add(new WorkItemTreeNode(wi, 0));
                }
                else
                {
                    WorkItemTreeNode parent = null;
                    try
                    {
                        parent = ans.DepthFirstNodes().Where(node => node.WorkItem.Id == wili.SourceId).Single();
                    }
                    catch (InvalidOperationException)
                    {
                        throw new InvalidOperationException(ModelResources.QueryNotWellFormedTree);
                    }

                    parent.Children.Add(new WorkItemTreeNode(wi, parent.Level + 1));
                }
            }

            return(ans);
        }
Ejemplo n.º 12
0
 public void Disconnect()
 {
     TeamProject           = null;
     TeamProjectCollection = null;
     WorkItemLinkInfos     = new WorkItemLinkInfo[0];
     if (AllChildren != null)
     {
         AllChildren.Clear();
     }
     if (BacklogChildren.Count > 0)
     {
         ApplyChildrenChangesOnUIThread(new List <BacklogChildren>());
     }
     if (BackLogItems != null)
     {
         BackLogItems.Clear();
     }
     LoginData       = new LoginData();
     ReportFolder    = null;
     ReportServerUrl = null;
     WorkItems       = null;
     OnDisconnected();
 }
Ejemplo n.º 13
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd)
     : base(0, linkTypeEnd)
 {
     LinkInfo = new WorkItemLinkInfo(0, 0, linkTypeEnd);
 }
        public bool TryGetOneHopQueryDefinitionWorkItemLinkInfo(out WorkItemLinkInfo[] workItemLinkInfos, TfsTeamProjectCollection tfsTeamProjectCollection, QueryDefinition queryDefinition, string projectName)
        {
            try
            {
                workItemLinkInfos = _teamPilgrimTfsService.GetLinkQueryDefinitionWorkItemLinkInfo(tfsTeamProjectCollection, queryDefinition, projectName);
                return true;
            }
            catch (Exception ex)
            {
                this.Logger().DebugException(ex);
                LastException = ex;
            }

            workItemLinkInfos = null;
            return false;
        }
Ejemplo n.º 15
0
 public void TargetMissingForLink(WorkItemLinkInfo queryLink, int parentId, int childId)
 {
     this.Info("Cannot add source WorkitemLink {0}->{1} (type {2}) as one of the target is not mapped."
               , queryLink.SourceId, queryLink.TargetId, queryLink.LinkTypeId);
 }
Ejemplo n.º 16
0
        //TODO:refactor it.
        public void GenerateReport(string project, Action <string> descriptionText)
        {
            var popup = new QueryReport {
                Project = project
            };
            Project currProject = tfsManager.GetProject(project);
            var     qm          = new QueryManager(currProject, popup.QueriesTree, tfsManager.ItemsStore);
            List <FieldDefinition> allFields = tfsManager.GetAllAvailableWorkItemFieldsForProject(project);
            string        queryName          = string.Empty;
            Query         query            = null;
            List <string> displayFieldList = null;

            qm.Query += qDef =>
            {
                if (qDef != null)
                {
                    tfsManager.ItemsStore.RefreshCache();
                    query            = new Query(tfsManager.ItemsStore, qDef.QueryText);
                    displayFieldList = query.DisplayFieldList.Cast <FieldDefinition>().Select(f => f.Name).ToList();
                    popup.QueryDef   = qDef;

                    // clear controls
                    popup.PropertiesList.SelectionMode = SelectionMode.Multiple;
                    popup.tbxHeader.Clear();
                    popup.PropertiesList.Items.Clear();
                    popup.PropertiesListBody.Items.Clear();
                    queryName = qDef.Name;
                    if (displayFieldList != null)
                    {
                        popup.PopulateQueryFields(allFields, displayFieldList);
                        popup.InsertButton.IsEnabled = true;
                    }
                }
                else
                {
                    popup.InsertButton.IsEnabled = false;
                }
            };



            switch (tfsManager.tfsVersion)
            {
            case TfsVersion.Tfs2011:
                popup.ManageQueriesLink.NavigateUri = new Uri(string.Format("{0}/{1}/_workitems", tfsManager.ItemsStore.TeamProjectCollection.Uri, project));
                break;

            case TfsVersion.Tfs2010:
                popup.ManageQueriesLink.NavigateUri = new Uri(string.Format("{0}/web/UI/Pages/WorkItems/QueryExplorer.aspx?pguid={1}", tfsManager.GetTfsUrl(), tfsManager.GetProject(project).Guid));
                break;
            }
            popup.Create(null, Icons.Report);

            //Generate Report from WI list
            if (popup.byWIIDsTabItem.IsSelected && !popup.IsCanceled)
            {
                tfsManager.ItemsStore.RefreshCache();
                query     = new Query(tfsManager.ItemsStore, popup.queryDef.QueryText);
                queryName = popup.queryDef.Name;
            }

            revisionDate = popup.onDate.SelectedDate;
            if (!popup.IsCanceled)
            {
                List <string> metaDataSelectedItems = GetSelectedItemsFromCheckListBox(popup.PropertiesList);
                List <string> bodySelectedItems     = GetSelectedItemsFromCheckListBox(popup.PropertiesListBody);
                bool          includeAttachments    = popup.IncludeAttachmentsCheckBox.IsChecked.Value;

                var pd = new ProgressDialog();

                string uiCulture = Thread.CurrentThread.CurrentUICulture.ToString();

                pd.Execute(ts =>
                {
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiCulture);
                    pd.UpdateProgress(0, ResourceHelper.GetResourceString("MSG_RETRIEVING_WORK_ITEMS"), true);
                    SetProjectTextWithUrl(project, string.Format("{0}: {1}", ResourceHelper.GetResourceString("MSG_REPORT_TITLE"), queryName));

                    if (query.IsLinkQuery)
                    {
                        WorkItemLinkInfo[] queryResults = query.RunLinkQuery();

                        // Dictionary<Id,HierarchyLevel>
                        var hierarchy      = new Dictionary <int, int>();
                        int hierarchyLevel = 1;
                        int itemsCount     = queryResults.Count();
                        for (int i = 0; i < itemsCount; i++)
                        {
                            try
                            {
                                if (!ts.IsCancellationRequested)
                                {
                                    WorkItemLinkInfo item = queryResults[i];
                                    WorkItem workItem     = tfsManager.ItemsStore.GetWorkItem(item.TargetId);
                                    DateTime date         = DateTime.MaxValue;

                                    popup.Dispatcher.Invoke((Action)(() =>
                                    {
                                        date = popup.onDate.SelectedDate.GetValueOrDefault(date);
                                    }));

                                    if (date != DateTime.MaxValue)
                                    {
                                        Revision onDateItem = GetLastRevision(workItem, date);

                                        if (onDateItem != null)
                                        {
                                            pd.UpdateProgress(Convert.ToInt32(i / (decimal)itemsCount * 100), string.Format(ResourceHelper.GetResourceString("REPORT_PROGRESS"), i + 1, itemsCount, onDateItem.WorkItem.Title), false);
                                            AddHierarchy(hierarchy, ref hierarchyLevel, ref item);

                                            // TODO:Move to separate Method
                                            WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, onDateItem, hierarchyLevel);
                                            //WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, workItem, hierarchyLevel);
                                        }
                                    }
                                    else
                                    {
                                        pd.UpdateProgress(Convert.ToInt32(i / (decimal)itemsCount * 100), string.Format(ResourceHelper.GetResourceString("REPORT_PROGRESS"), i + 1, itemsCount, workItem.Title), false);
                                        AddHierarchy(hierarchy, ref hierarchyLevel, ref item);
                                        WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, workItem, hierarchyLevel);
                                    }
                                }
                            }
                            //catch (DeniedOrNotExistException)
                            //{
                            //}
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, ResourceHelper.GetResourceString("ERROR_TEXT"), MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                    }
                    else
                    {
                        WorkItemCollection queryResults = query.RunQuery();
                        int counter = 0;
                        foreach (WorkItem item in queryResults)
                        {
                            DateTime date = DateTime.MaxValue;
                            popup.Dispatcher.Invoke((Action)(() =>
                            {
                                date = popup.onDate.SelectedDate.GetValueOrDefault(date);
                            }));

                            if (date != DateTime.MaxValue)
                            {
                                Revision onDateItem = GetLastRevision(item, date);
                                if (onDateItem != null)
                                {
                                    if (!ts.IsCancellationRequested)
                                    {
                                        counter++;

                                        pd.UpdateProgress(Convert.ToInt32(counter / (decimal)queryResults.Count * 100), string.Format(ResourceHelper.GetResourceString("REPORT_PROGRESS"), counter, queryResults.Count, onDateItem.WorkItem.Title), false);

                                        //TODO:Move to separate Method
                                        WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, onDateItem);
                                        //WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, item);
                                    }
                                }
                            }
                            else
                            {
                                if (!ts.IsCancellationRequested)
                                {
                                    counter++;

                                    pd.UpdateProgress(Convert.ToInt32(counter / (decimal)queryResults.Count * 100), string.Format(ResourceHelper.GetResourceString("REPORT_PROGRESS"), counter, queryResults.Count, item.Title), false);

                                    WriteReport(descriptionText, metaDataSelectedItems, bodySelectedItems, includeAttachments, item);
                                    // TODO:Move to separate Method
                                }
                            }
                        }
                    }
                });
                pd.Create(string.Format("{0} {1}", project, ResourceHelper.GetResourceString("MSG_REPORT_TITLE")), Icons.Report);
            }
        }
 private WorkItemLinkInfoWrapper(WorkItemLinkInfo instance)
 {
     r_Instance = instance;
 }
Ejemplo n.º 18
0
 public void AnalyzingSourceLink(WorkItemLinkInfo queryLink)
 {
     this.Info("Analyzing source WorkitemLink {0}->{1} (type {2}).", queryLink.SourceId, queryLink.TargetId, queryLink.LinkTypeId);
 }
 static partial void RealInstanceFactory(ref LinkInfo real, string callerName)
 {
     real = new WorkItemLinkInfo();
 }
        /// <summary>
        /// Batch retrieves work items based on the ID
        /// </summary>
        /// <param name="links">The list of work item ID's to retrieve the full work item for</param>
        /// <param name="q">The query</param>
        /// <returns>A dictionary where the key is the Work Item ID and the value is the Work Item</returns>
        private Dictionary<int, WorkItem> GetWorkItemsById(WorkItemLinkInfo[] links, Query q)
        {
            //Some place to store the work items and their ID's
            Dictionary<int, WorkItem> results = new Dictionary<int, WorkItem>();

            // Do batch read of work items from collected IDs
            WorkItemCollection workItems = GetWorkItemsFromLinkInfo(links, q);

            //Add the work items to the dictionary. This is necessary because when we
            //construct the layout of the results, we need to get the work items from
            //the ID's so they are ordered correctly.
            if (workItems != null)
            {
                foreach (WorkItem wi in workItems)
                    results.Add(wi.Id, wi);
            }

            return results;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 从WorkItemLinkInfo对象中获取WorkItemLinkInfoDetails。
        /// </summary>
        public WorkItemLinkInfoDetails GetDetailsFromWorkItemLinkInfo(WorkItemLinkInfo linkInfo)
        {
            if (linkInfo == null)
            {
                throw new ArgumentNullException("linkInfo");
            }

            if (this.LinkTypes.ContainsKey(linkInfo.LinkTypeId))
            {
                WorkItemLinkInfoDetails details = new WorkItemLinkInfoDetails(
                   linkInfo,
                   this.WorkItemStore.GetWorkItem(linkInfo.SourceId),
                   this.WorkItemStore.GetWorkItem(linkInfo.TargetId),
                   this.LinkTypes[linkInfo.LinkTypeId]);
                return details;
            }
            else
            {
                throw new ApplicationException("Cannot find WorkItemLinkType!");
            }
        }
Ejemplo n.º 22
0
 static partial void RealInstanceFactory(ref WorkItemLinkInfo real, [CallerMemberName] string callerName = "");
Ejemplo n.º 23
0
 public void LinkExists(WorkItemLinkInfo queryLink, WorkItemLinkInfo match)
 {
     this.Info("WorkitemLink source {0}->{1} (type {2}) already maps to {3}->{4} (type {5})."
               , queryLink.SourceId, queryLink.TargetId, queryLink.LinkTypeId
               , match.SourceId, match.TargetId, match.LinkTypeId);
 }
 public static WorkItemLinkInfoWrapper GetWrapper(WorkItemLinkInfo src)
 {
     return(default(WorkItemLinkInfoWrapper));
 }
Ejemplo n.º 25
0
 public void LinkExists(WorkItemLinkInfo queryLink, WorkItemLink relationship)
 {
     this.Info("WorkitemLink source {0}->{1} (type {2}) already maps to {3}->{4} (type {5})."
               , queryLink.SourceId, queryLink.TargetId, queryLink.LinkTypeId
               , relationship.SourceId, relationship.TargetId, relationship.LinkTypeEnd.LinkType.ReferenceName);
 }
        /// <summary>
        /// Gets further details of the links in support of the GetWorkItemsById method
        /// </summary>
        /// <param name="links">The list of work items to get the details for</param>
        /// <param name="q">The query to execute</param>
        /// <returns>A WorkItemCollection containing all requested links</returns>
        private WorkItemCollection GetWorkItemsFromLinkInfo(WorkItemLinkInfo[] links, Query q)
        {
            //Check to see if there are any links to queryy
            if (links == null || links.GetLength(0) < 1)
                return null;

            //Holds the list of work item ID's to query for
            List<int> wisInBatch = new List<int>();

            // Get IDs for work items represented by post items:
            BatchReadParameterCollection batchReadParameters = new BatchReadParameterCollection();

            try
            {
                //Add all of the work item target ID's to the batch parameters for querying
                for (int wiIndex = 0; wiIndex < links.Length; ++wiIndex)
                {
                    int wiId = links[wiIndex].TargetId;
                    if (wiId != -1 && !wisInBatch.Contains(wiId))
                    {
                        batchReadParameters.Add(new BatchReadParameter(wiId));
                        wisInBatch.Add(wiId);
                    }
                }
                //Get the work item collection which contains all of the ID's
                return _wis.Query(batchReadParameters, "select [System.Id] from WorkItems");
            }
            catch
            {
                return null;
            }
        }
Ejemplo n.º 27
0
 private static void AddHierarchy(Dictionary <int, int> hierarchy, ref int hierarchyLevel, ref WorkItemLinkInfo item)
 {
     if (item.SourceId != 0 && !hierarchy.ContainsKey(item.TargetId))
     {
         if (hierarchy.ContainsKey(item.SourceId))
         {
             hierarchyLevel = hierarchy[item.SourceId] + 1;
             hierarchy.Add(item.TargetId, hierarchyLevel);
         }
         else
         {
             hierarchyLevel = 2;
             hierarchy.Add(item.TargetId, hierarchyLevel);
         }
     }
     else
     {
         hierarchyLevel = 1;
     }
 }
        /// <summary>
        /// Configures a query shim to simulate Run on TFS Query objects
        /// </summary>
        private void SetupQueryShim(FakeTfsContext tfsContext)
        {
            ShimQuery.ConstructorWorkItemStoreString = (q, ws, wi) =>
            {
                ShimQuery query = new ShimQuery();

                query.QueryStringGet = () => wi;

                q = query;
            };

            var workItem = new ShimWorkItem();
            workItem.IdGet = () => 5;
            workItem.TitleGet = () => "Linked Work Item";

            var workItemLinkInfo = new WorkItemLinkInfo();
            workItemLinkInfo.TargetId = 5;

            tfsContext.AddWorkItem(workItem);

            ShimWorkItemCollection collection = SetupWorkItemCollection(workItem);

            ShimQuery.AllInstances.IsLinkQueryGet = (q) => false;
            ShimQuery.AllInstances.RunQuery = (q) => collection;
            ShimQuery.AllInstances.RunLinkQuery = (q) => new List<WorkItemLinkInfo>() { workItemLinkInfo }.ToArray();
        }
Ejemplo n.º 29
0
 public MockRelatedLink(IWorkItemLinkTypeEnd linkTypeEnd, int targetId)
     : base(targetId, linkTypeEnd)
 {
     LinkInfo = new WorkItemLinkInfo(0, targetId, linkTypeEnd);
 }