コード例 #1
0
ファイル: FakeUtils.cs プロジェクト: vidyabs/CustomActivities
        internal static WorkItemStore GetFakeWorkItemStore(List <WorkItemInfo> workItems)
        {
            ShimQuery.ConstructorWorkItemStoreString = (q, store, wiql) =>
            {
                var fakeQ = new ShimQuery(q)
                {
                    WorkItemStoreGet = () => store,
                    QueryStringGet   = () => wiql,
                    RunLinkQuery     = () =>
                    {
                        // extract the targetIds from the wiql
                        var start  = q.QueryString.IndexOf("IN (") + 4;
                        var end    = q.QueryString.IndexOf(")", start);
                        var idArgs = q.QueryString.Substring(start, end - start);
                        var ids    = idArgs.Split(new[] { ", " }, StringSplitOptions.None).ToList().ConvertAll(s => int.Parse(s));

                        var children = from w in workItems
                                       where ids.Contains(w.Id)
                                       select new WorkItemLinkInfo()
                        {
                            LinkTypeId = w.ParentId == 0 ? 0 : 2,
                            SourceId   = w.ParentId,
                            TargetId   = w.Id
                        };
                        var parents = from w in children
                                      where w.SourceId != 0
                                      select new WorkItemLinkInfo()
                        {
                            LinkTypeId = 0,
                            SourceId   = 0,
                            TargetId   = w.SourceId
                        };
                        return(children.Union(parents).ToArray());
                    }
                };
            };

            return(new ShimWorkItemStore()
            {
                QueryInt32ArrayString = (ids, query) =>
                {
                    var col = new ShimWorkItemCollection()
                    {
                        CountGet = () => workItems.Where(w => ids.Contains(w.Id)).Count()
                    };
                    col.Bind(workItems.Where(w => ids.Contains(w.Id)).ToList().ConvertAll(w => (WorkItem) new ShimWorkItem()
                    {
                        IdGet = () => w.Id
                    }));
                    return col;
                }
            });
        }
コード例 #2
0
        private ShimWorkItemCollection SetupWorkItemCollection(params ShimWorkItem[] workItems)
        {
            var collection = new ShimWorkItemCollection();

            collection.Bind(workItems.Select(w => w.Instance));

            return collection;
        }
コード例 #3
0
		internal static WorkItemStore GetFakeWorkItemStore(List<WorkItemInfo> workItems)
		{
			ShimQuery.ConstructorWorkItemStoreString = (q, store, wiql) =>
			{
				var fakeQ = new ShimQuery(q) 
				{
					WorkItemStoreGet = () => store,
					QueryStringGet = () => wiql,
					RunLinkQuery = () =>
					{
						// extract the targetIds from the wiql
						var start = q.QueryString.IndexOf("IN (") + 4;
						var end = q.QueryString.IndexOf(")", start);
						var idArgs = q.QueryString.Substring(start, end - start);
						var ids = idArgs.Split(new[] { ", " }, StringSplitOptions.None).ToList().ConvertAll(s => int.Parse(s));

						var children = from w in workItems
									   where ids.Contains(w.Id)
									   select new WorkItemLinkInfo()
									   {
										   LinkTypeId = w.ParentId == 0 ? 0 : 2,
										   SourceId = w.ParentId,
										   TargetId = w.Id
									   };
						var parents = from w in children
									  where w.SourceId != 0
									  select new WorkItemLinkInfo()
									  {
										  LinkTypeId = 0,
										  SourceId = 0,
										  TargetId = w.SourceId
									  };
						return children.Union(parents).ToArray();
					}
				};
			};

			return new ShimWorkItemStore()
			{
				QueryInt32ArrayString = (ids, query) =>
					{
						var col = new ShimWorkItemCollection() { CountGet = () => workItems.Where(w => ids.Contains(w.Id)).Count() };
						col.Bind(workItems.Where(w => ids.Contains(w.Id)).ToList().ConvertAll(w => (WorkItem)new ShimWorkItem() { IdGet = () => w.Id }));
						return col;
					}
			};
		}