public async Task QueuingTask_WhenAll_WhenCalled_ThenOnlyStartsFourTasksAtTheSameTime()
        {
            var totalTasksDone = new List <int> {
                0, 4, 8
            };
            var startDate = DateTime.Now;
            var list      = new List <int> {
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            };
            var totalDone = 0;

            var result = await QueuingTask.WhenAll(list, async x =>
            {
                Assert.IsTrue(totalTasksDone.Contains(totalDone));

                await Task.Delay(2000);

                totalDone++;

                return(new List <int> {
                    x
                });
            });

            Assert.AreEqual(list.Count, result.Count());
            Assert.IsTrue(DateTime.Now.Ticks >= startDate.Ticks + 6000);
        }
        public async Task <IEnumerable <string> > GetAllWorkItemTypesAsync()
        {
            var vssConnection = new VssConnection(_versionControlServer.TeamProjectCollection.Uri, _versionControlServer.TeamProjectCollection.ClientCredentials);

            using (var projectClientHttpClient = await vssConnection.GetClientAsync <ProjectHttpClient>())
                using (var workItemTrackingHttpClient = await vssConnection.GetClientAsync <WorkItemTrackingHttpClient>())
                {
                    var projects = await projectClientHttpClient.GetProjects(ProjectState.All, null, null, null, null);

                    var projectGuids = projects.Select(x => x.Id).ToList();

                    var result = await QueuingTask.WhenAll(projectGuids, x => workItemTrackingHttpClient.GetWorkItemTypesAsync(x));

                    return(result
                           .Select(x => x.Name)
                           .Distinct()
                           .OrderBy(x => x)
                           .ToList());
                }
        }
Beispiel #3
0
        public async Task <IEnumerable <int> > GetWorkItemIdsAsync(IEnumerable <int> changesetIds, IEnumerable <string> workItemTypesToExclude)
        {
            var associatedWorkItems = await QueuingTask.WhenAll(changesetIds, x => GetAssociatedWorkItemIdsAsync(x, workItemTypesToExclude ?? Enumerable.Empty <string>()));

            return(associatedWorkItems.Distinct().OrderBy(x => x).ToList());
        }