Esempio n. 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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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"));
        }
Esempio n. 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);
        }
Esempio n. 19
0
 internal static bool IsVersion(this IListBlobItem b, VersionSpec version)
 {
     return(b is CloudBlockBlob &&
            ((CloudBlockBlob)b).Name.Contains(version.ToString()));
 }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        private static string BuildPattern(VersionSpec version)
        {
            var path = $"{version.Platform}/{version.Architecture}/*{version.ToString()}*";

            return(path);
        }