Пример #1
0
        public async Task <IDictionary <string, PackageLookupResult> > FindVersionUpdates(
            IEnumerable <PackageIdentity> packages,
            NuGetSources sources,
            VersionChange allowedChange,
            UsePrerelease usePrerelease)
        {
            var latestOfEach = packages
                               .GroupBy(pi => pi.Id.ToUpperInvariant())
                               .Select(HighestVersion);

            var lookupTasks = latestOfEach
                              .Select(id => _packageLookup.FindVersionUpdate(id, sources, allowedChange, usePrerelease))
                              .ToList();

            await Task.WhenAll(lookupTasks);

            var result = new Dictionary <string, PackageLookupResult>(StringComparer.OrdinalIgnoreCase);

            foreach (var lookupTask in lookupTasks)
            {
                var serverVersions = lookupTask.Result;
                ProcessLookupResult(serverVersions, result);
            }

            return(result);
        }
Пример #2
0
        public async Task <IDictionary <PackageIdentity, PackageLookupResult> > FindVersionUpdates(
            IEnumerable <PackageIdentity> packages,
            NuGetSources sources,
            VersionChange allowedChange,
            UsePrerelease usePrerelease
            )
        {
            var lookupTasks = packages
                              .Distinct()
                              .GroupBy(pi => (pi.Id, MaxVersion: GetMaxVersion(pi, allowedChange)))
                              .Select(HighestVersion)
                              .Select(id => new { Package = id, Update = _packageLookup.FindVersionUpdate(id, sources, allowedChange, usePrerelease) })
                              .ToList();

            await Task.WhenAll(lookupTasks.Select(l => l.Update));

            var result = new Dictionary <PackageIdentity, PackageLookupResult>();

            foreach (var lookupTask in lookupTasks)
            {
                ProcessLookupResult(lookupTask.Package, lookupTask.Update.Result, result);
            }

            return(result);
        }
        private static void ApiHasNewVersionForPackage(IApiPackageLookup lookup, string packageName)
        {
            var responseMetaData = new PackageSearchMedatadata(
                new PackageIdentity(packageName, new NuGetVersion(2, 3, 4)), "test", DateTimeOffset.Now);

            lookup.FindVersionUpdate(Arg.Is <PackageIdentity>(pm => pm.Id == packageName), Arg.Any <VersionChange>())
            .Returns(new PackageLookupResult(VersionChange.Major, responseMetaData, responseMetaData, responseMetaData));
        }
Пример #4
0
        private static void ApiHasNewVersionForPackage(IApiPackageLookup lookup, string packageName)
        {
            var responseMetaData = new PackageSearchMetadata(
                new PackageIdentity(packageName, new NuGetVersion(2, 3, 4)), new PackageSource("http://none"),
                DateTimeOffset.Now, null);

            lookup.FindVersionUpdate(Arg.Is <PackageIdentity>(pm => pm.Id == packageName),
                                     Arg.Any <NuGetSources>(), Arg.Any <VersionChange>(), Arg.Any <UsePrerelease>())
            .Returns(new PackageLookupResult(VersionChange.Major, responseMetaData, responseMetaData, responseMetaData));
        }
Пример #5
0
        public void Initialize()
        {
            _apiPackageLookup = Substitute.For <IApiPackageLookup>();

            _apiPackageLookup
            .FindVersionUpdate(
                Arg.Any <PackageIdentity>(),
                Arg.Any <NuGetSources>(),
                VersionChange.Minor,
                Arg.Any <UsePrerelease>()
                )
            .Returns(ci =>
                     GetPackageLookupResult(
                         (PackageIdentity)ci[0],
                         (VersionChange)ci[2]
                         )
                     );
        }
Пример #6
0
        public async Task <Dictionary <string, PackageLookupResult> > FindVersionUpdates(
            IEnumerable <PackageIdentity> packages, VersionChange allowedChange)
        {
            var latestOfEach = packages
                               .GroupBy(pi => pi.Id)
                               .Select(HighestVersion);

            var lookupTasks = latestOfEach
                              .Select(id => _packageLookup.FindVersionUpdate(id, allowedChange))
                              .ToList();

            await Task.WhenAll(lookupTasks);

            var result = new Dictionary <string, PackageLookupResult>();

            foreach (var lookupTask in lookupTasks)
            {
                var serverVersions = lookupTask.Result;
                ProcessLookupResult(serverVersions, result);
            }

            return(result);
        }