Exemple #1
0
        public bool Match(Path path, VersionSpec version)
        {
            var search    = $"{version.ToString()}/";
            var pathMatch = path.FullPath.StartsWith(search);
            var nameMatch = _forceNameMatch
                ? path.GetFilenameWithoutExtension().Contains(version.ToString())
                : true;
            var platMatch = path.GetFilenameWithoutExtension().Contains(version.Architecture) &&
                            path.GetFilenameWithoutExtension().Contains(version.Platform);

            return(pathMatch && nameMatch && platMatch);
        }
        public bool Match(Path path, VersionSpec version)
        {
            var search   = $"{version.ToString()}/{version.Platform}/{version.Architecture}";
            var matching = path.FullPath.StartsWith(search) ||
                           path.FullPath.TrimStart('.', '/').StartsWith(search);
            var nameMatch = _forceNameMatch ? path.GetFilename().Contains(version) : true;

            return(matching && nameMatch);
        }
        public bool Match(Path path, VersionSpec version)
        {
            var search       = $"{version.ToString()}/";
            var versionMatch = path.FullPath.StartsWith(search);
            var nextSegment  = path.FullPath.Split('/').Skip(1).First();
            var platMatch    = nextSegment.Contains(version.Platform) && nextSegment.Contains(version.Architecture);
            var nameMatch    = _forceNameMatch ? path.GetFilenameWithoutExtension().Contains(version.ToString()) : true;

            return(versionMatch && platMatch && nameMatch);
        }
Exemple #4
0
        public bool Match(Path path, VersionSpec version)
        {
            var name      = path.GetFilename();
            var nameMatch = name.Contains(version.Architecture) &&
                            name.Contains(version.Platform) &&
                            name.Contains(version.ToString());

            //this is a bit heavy-handed since other backends likely won't adopt the GitHub conventions..
            var segMatch = SpecParser.Parse(name).Equals(version);

            return(nameMatch && segMatch);
        }
Exemple #5
0
        public void ToStringMinVersionExclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMinInclusive = false,
                MinVersion = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("(1.0, )", value);
        }
Exemple #6
0
        public void ToStringMaxVersionInclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMaxInclusive = true,
                MaxVersion = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("(, 1.0]", value);
        }
Exemple #7
0
        public void ToStringMinVersionInclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMinInclusive = true,
                MinVersion     = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("1.0", value);
        }
Exemple #8
0
        public void ToStringMaxVersionExclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMaxInclusive = false,
                MaxVersion     = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("(, 1.0)", value);
        }
Exemple #9
0
        public void ToStringMaxVersionInclusive()
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMaxInclusive = true,
                MaxVersion     = new SemanticVersion("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal("(, 1.0]", value);
        }
Exemple #10
0
        public void ToStringMinVersionExclusive()
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMinInclusive = false,
                MinVersion     = new SemanticVersion("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal("(1.0, )", value);
        }
        public void ToStringMinVersionInclusive()
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMinInclusive = true,
                MinVersion = new SemanticVersion("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal("1.0", value);
        }
Exemple #12
0
        public void ToStringMinVersionExclusiveMaxInclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMaxInclusive = true,
                IsMinInclusive = false,
                MaxVersion     = new Version("3.0"),
                MinVersion     = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("(1.0, 3.0]", value);
        }
Exemple #13
0
        public void ToStringSemVer200(string min, string max, string expected)
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMaxInclusive = false,
                IsMinInclusive = false,
                MaxVersion     = new SemanticVersion(max),
                MinVersion     = new SemanticVersion(min),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal(expected, value);
        }
Exemple #14
0
        public void ToStringMinVersionInclusiveMaxExclusive()
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMaxInclusive = false,
                IsMinInclusive = true,
                MaxVersion     = new SemanticVersion("4.0"),
                MinVersion     = new SemanticVersion("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal("[1.0, 4.0)", value);
        }
        public void GetUpdates()
        {
            var packages = new[] {new LucenePackage(path => null)  {Id = "id1", Version = new StrictSemanticVersion("2.0")}};

            var constraint = new VersionSpec {MinVersion = new SemanticVersion("1.0"), IsMinInclusive = false};
            repo.Setup(r => r.GetUpdates(
                It.Is<IEnumerable<IPackage>>(p => p.Count() == 1),
                false,
                false,
                It.Is<IEnumerable<FrameworkName>>(p => !p.Any()),
                It.Is<IEnumerable<IVersionSpec>>(p => p.Single().ToString() == constraint.ToString())))
                .Returns(packages);

            var result = service.GetUpdates("id1", "1.0", false, false, "", "");

            repo.VerifyAll();

            Assert.That(result.Count(), Is.EqualTo(1));
            Assert.That(result.First().Id, Is.EqualTo("id1"));
            Assert.That(result.First().Version, Is.EqualTo("2.0"));
        }
        public void GetUpdates()
        {
            var packages = new[] {new LucenePackage(path => null)  {Id = "id1", Version = new StrictSemanticVersion("2.0")}};

            var constraint = new VersionSpec {MinVersion = new SemanticVersion("1.0"), IsMinInclusive = false};
            repo.Setup(r => r.GetUpdates(
                It.Is<IEnumerable<IPackage>>(p => p.Count() == 1),
                false,
                false,
                It.Is<IEnumerable<FrameworkName>>(p => !p.Any()),
                It.Is<IEnumerable<IVersionSpec>>(p => p.Single().ToString() == constraint.ToString())))
                .Returns(packages);

            var result = controller.GetUpdates("id1", "1.0", false, false, "", "");

            repo.VerifyAll();

            Assert.That(result, Is.InstanceOf<OkNegotiatedContentResult<IQueryable<ODataPackage>>>());
            var queryable = ((OkNegotiatedContentResult<IQueryable<ODataPackage>>) result).Content;

            Assert.That(queryable.Count(), Is.EqualTo(1));
            Assert.That(queryable.First().Id, Is.EqualTo("id1"));
            Assert.That(queryable.First().Version, Is.EqualTo("2.0"));
        }
        public void GetUpdates()
        {
            var packages = new[] { new LucenePackage(path => null)
                                   {
                                       Id = "id1", Version = new StrictSemanticVersion("2.0")
                                   } };

            var constraint = new VersionSpec {
                MinVersion = new SemanticVersion("1.0"), IsMinInclusive = false
            };

            repo.Setup(r => r.GetUpdates(
                           It.Is <IEnumerable <IPackage> >(p => p.Count() == 1),
                           false,
                           false,
                           It.Is <IEnumerable <FrameworkName> >(p => !p.Any()),
                           It.Is <IEnumerable <IVersionSpec> >(p => p.Single().ToString() == constraint.ToString())))
            .Returns(packages);

            var result = controller.GetUpdates("id1", "1.0", false, false, "", "");

            repo.VerifyAll();

            Assert.That(result, Is.InstanceOf <OkNegotiatedContentResult <IQueryable <ODataPackage> > >());
            var queryable = ((OkNegotiatedContentResult <IQueryable <ODataPackage> >)result).Content;

            Assert.That(queryable.Count(), Is.EqualTo(1));
            Assert.That(queryable.First().Id, Is.EqualTo("id1"));
            Assert.That(queryable.First().Version, Is.EqualTo("2.0"));
        }
Exemple #18
0
        public void ToStringMinVersionInclusiveMaxExclusive()
        {
            // Arrange
            var spec = new VersionSpec {
                IsMaxInclusive = false,
                IsMinInclusive = true,
                MaxVersion = new Version("4.0"),
                MinVersion = new Version("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.AreEqual("[1.0, 4.0)", value);
        }
 internal static bool IsVersion(this IListBlobItem b, VersionSpec version)
 {
     return(b is CloudBlockBlob &&
            ((CloudBlockBlob)b).Name.Contains(version.ToString()));
 }
        public void ToStringMinVersionExclusiveMaxInclusive()
        {
            // Arrange
            var spec = new VersionSpec
            {
                IsMaxInclusive = true,
                IsMinInclusive = false,
                MaxVersion = new SemanticVersion("3.0"),
                MinVersion = new SemanticVersion("1.0"),
            };

            // Act
            string value = spec.ToString();

            // Assert
            Assert.Equal("(1.0, 3.0]", value);
        }
Exemple #21
0
        private static string BuildPattern(VersionSpec version)
        {
            var path = $"{version.Platform}/{version.Architecture}/*{version.ToString()}*";

            return(path);
        }