public PackageVersionSummary(StrictSemanticVersion version, DateTimeOffset lastUpdated, int versionDownloadCount, Link link)
 {
     this.version = version;
     this.lastUpdated = lastUpdated;
     this.versionDownloadCount = versionDownloadCount;
     this.link = link;
 }
 public PackageVersionSummary(string id, string title, StrictSemanticVersion version, DateTimeOffset lastUpdated, int versionDownloadCount, Link link)
 {
     this.id                   = id;
     this.title                = title;
     this.version              = version;
     this.lastUpdated          = lastUpdated;
     this.versionDownloadCount = versionDownloadCount;
     this.link                 = link;
 }
 public PackageVersionSummary(string id, string title, StrictSemanticVersion version, DateTimeOffset lastUpdated, int versionDownloadCount, Link link)
 {
     this.id = id;
     this.title = title;
     this.version = version;
     this.lastUpdated = lastUpdated;
     this.versionDownloadCount = versionDownloadCount;
     this.link = link;
 }
        /// <summary>
        /// Parses a version string using strict SemVer rules.
        /// </summary>
        public static bool TryParseStrict(string value, out SemanticVersion version)
        {
            version = null;

            StrictSemanticVersion semVer = null;

            if (TryParse(value, out semVer))
            {
                version = new SemanticVersion(semVer.Major, semVer.Minor, semVer.Patch, 0, semVer.ReleaseLabels, semVer.Metadata);
            }

            return(true);
        }
 private static LucenePackage CreatePackage(StrictSemanticVersion version)
 {
     return(new LucenePackage(_ => new MemoryStream(Encoding.UTF8.GetBytes("<fake package contents>")))
     {
         Id = "Sample",
         Version = version,
         PackageHash = "fake hash",
         PackageSize = 12345678L,
         Created = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero),
         Published = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero),
         LastUpdated = new DateTimeOffset(4000, 1, 1, 0, 0, 0, TimeSpan.Zero),
     });
 }
Exemple #6
0
 private static LucenePackage CreatePackage(StrictSemanticVersion version)
 {
     return(new LucenePackage(_ => new MemoryStream(Encoding.UTF8.GetBytes("<fake package contents>")))
     {
         Id = "Sample",
         Version = version,
         PackageHash = "fake hash",
         PackageSize = 12345678L,
         Created = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero),
         Published = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero),
         LastUpdated = new DateTimeOffset(4000, 1, 1, 0, 0, 0, TimeSpan.Zero),
         Files = new[] { Path.Combine("src", "Class1.cs"), Path.Combine("lib", "net35", "Sample.PDB") }
     });
 }
Exemple #7
0
        private void AddSamplePackage(string id, string version)
        {
            var semanticVersion = new StrictSemanticVersion(version);

            packages.Add(new LucenePackage(_ => new MemoryStream())
            {
                Id = id, Version = semanticVersion
            });

            var all = packages.Where(p => p.Id == id).OrderBy(p => p.Version).ToList();

            all.ForEach(p => p.IsLatestVersion = p.IsAbsoluteLatestVersion = false);
            var last = all.Last();

            last.IsLatestVersion = last.IsAbsoluteLatestVersion = true;
        }
        static bool EqualsOneWay(IVersionComparer comparer, string version1, string version2)
        {
            // Arrange
            var a = SemanticVersion.Parse(version1);
            var b = SemanticVersion.Parse(version2);
            StrictSemanticVersion c = SemanticVersion.Parse(version1);
            StrictSemanticVersion d = SemanticVersion.Parse(version2);

            // Act
            var match = Compare(comparer, version1, version2) == 0;

            match &= comparer.Equals(a, b);
            match &= comparer.Equals(a, d);
            match &= comparer.Equals(c, d);
            match &= comparer.Equals(c, b);

            return(match);
        }
        static int CompareOneWay(IVersionComparer comparer, string version1, string version2)
        {
            // Arrange
            var a = SemanticVersion.Parse(version1);
            var b = SemanticVersion.Parse(version2);
            var c = StrictSemanticVersion.Parse(version1);
            var d = StrictSemanticVersion.Parse(version2);

            // Act
            var results = new List <int>();

            results.Add(comparer.Compare(a, b));
            results.Add(comparer.Compare(a, d));
            results.Add(comparer.Compare(c, b));
            results.Add(comparer.Compare(c, d));

            // Assert
            Assert.True(results.FindAll(x => x == results[0]).Count == results.Count);

            return(results[0]);
        }
        public IEnumerable<IPackage> GetUpdates(IEnumerable<IPackageName> packages, bool includePrerelease, bool includeAllVersions,
            IEnumerable<FrameworkName> targetFrameworks, IEnumerable<IVersionSpec> versionConstraints)
        {
            var baseQuery = LucenePackages;

            if (!includePrerelease)
            {
                baseQuery = baseQuery.Where(pkg => !pkg.IsPrerelease);
            }

            var targetFrameworkList = (targetFrameworks ?? Enumerable.Empty<FrameworkName>()).ToList();
            var versionConstraintList = (versionConstraints ?? Enumerable.Empty<IVersionSpec>()).ToList();

            var results = new List<IPackage>();
            var i = 0;

            foreach (var current in packages)
            {
                var ii = i;
                var id = current.Id;
                var currentVersion = new StrictSemanticVersion(current.Version);
                var matchedPackages = (IEnumerable<LucenePackage>)baseQuery.Where(pkg => pkg.Id == id).OrderBy(pkg => pkg.Version).ToList();

                if (targetFrameworkList.Any())
                {
                    matchedPackages = matchedPackages.Where(pkg => targetFrameworkList.Any(fwk => VersionUtility.IsCompatible(fwk, pkg.GetSupportedFrameworks())));
                }

                matchedPackages = matchedPackages.Where(pkg => pkg.Version > currentVersion);

                if (versionConstraintList.Any() && versionConstraintList[ii] != null)
                {
                    matchedPackages = matchedPackages.Where(pkg => versionConstraintList[ii].Satisfies(pkg.Version.SemanticVersion));
                }

                if (includeAllVersions)
                {
                    results.AddRange(matchedPackages);
                }
                else
                {
                    var latest = matchedPackages.LastOrDefault();
                    if (latest != null)
                    {
                        results.Add(latest);
                    }
                }

                i++;
            }

            return results;
        }
 public TestPackage(string id, string version)
     : this()
 {
     Id = id;
     Version = new StrictSemanticVersion(version);
 }
        private void AddSamplePackage(string id, string version)
        {
            var semanticVersion = new StrictSemanticVersion(version);

            packages.Add(new LucenePackage(_ => new MemoryStream()) { Id = id, Version = semanticVersion });

            var all = packages.Where(p => p.Id == id).OrderBy(p => p.Version).ToList();
            all.ForEach(p => p.IsLatestVersion = p.IsAbsoluteLatestVersion = false);
            var last = all.Last();
            
            last.IsLatestVersion = last.IsAbsoluteLatestVersion = true;
        }
        public IEnumerable<IPackage> GetUpdates(IEnumerable<IPackage> packages, bool includePrerelease, bool includeAllVersions, IEnumerable<FrameworkName> targetFramework)
        {
            var baseQuery = LucenePackages;

            if (!includeAllVersions)
            {
                baseQuery = baseQuery.Where(pkg => pkg.IsLatestVersion);
            }

            if (!includePrerelease)
            {
                baseQuery = baseQuery.Where(pkg => !pkg.IsPrerelease);
            }

            var results = new List<IPackage>();

            foreach (var current in packages)
            {
                var id = current.Id;
                var currentVersion = new StrictSemanticVersion(current.Version);
                results.AddRange(baseQuery.Where(pkg => pkg.Id == id && pkg.Version > currentVersion));
            }

            return results;
        }
Exemple #14
0
 public TestPackage(string id, string version)
     : this()
 {
     Id      = id;
     Version = new StrictSemanticVersion(version);
 }