Exemple #1
0
        public void GrammarCanParseVersion()
        {
            NuGetv2 n;
            NuGetv2 f  = NuGetv2.Grammar.NuGetv2Version.Parse("3.2.5-foo");
            NuGetv2 f2 = NuGetv2.Grammar.NuGetv2Version.Parse("3.1.0.3-foo");
            NuGetv2 f3 = NuGetv2.Grammar.NuGetv2Version.Parse("3.1.0.3-foo-bar");
            NuGetv2 f4 = NuGetv2.Grammar.NuGetv2Version.Parse("3.1.0.3-foo-v1-20200911.23");

            n = NuGetv2.Parse("3.2.5-foo");
            Assert.Equal(n, NuGetv2.Grammar.NuGetv2Version.Parse("3.2.5-foo"));
            Assert.Equal(3, n.Version.Major);
            Assert.Equal(2, n.Version.Minor);
            Assert.Equal(5, n.Version.Build);
            Assert.Equal("foo", n.SpecialVersion);

            n = NuGetv2.Parse("1.2.3.4-foo-v1-20200911.23");
            Assert.Equal(n, NuGetv2.Grammar.NuGetv2Version.Parse("1.2.3.4-foo-v1-20200911.23"));
            Assert.Equal(1, n.Version.Major);
            Assert.Equal(2, n.Version.Minor);
            Assert.Equal(3, n.Version.Build);
            Assert.Equal(3, n.Version.Build);
            Assert.Equal("foo-v1-20200911.23", n.SpecialVersion);

            n = NuGetv2.Grammar.NuGetv2Version.Parse("3.4.0199");

            //Assert.Throws<ParseException>(() => NuGetv2.Grammar.NuGetv2Version.Parse("A.2.3"));
            //Assert.Throws<ParseException>(() => NuGetv2.Grammar.NuGetv2Version.Parse("3.2.3.X"));
        }
Exemple #2
0
        public void GrammarCanParseVersion()
        {
            NuGetv2 f  = NuGetv2.Grammar.NuGetv2Version.Parse("3.2.5-foo");
            NuGetv2 f2 = NuGetv2.Grammar.NuGetv2Version.Parse("3.1.0.3-foo");
            NuGetv2 n  = NuGetv2.Parse("3.2.5-foo");

            Assert.Equal(n, NuGetv2.Grammar.NuGetv2Version.Parse("3.2.5-foo"));
            Assert.Equal(n.Version.Major, 3);
            Assert.Equal(n.SpecialVersion, "foo");
            Assert.Equal(n.Version.Minor, 2);
            Assert.Equal(n.Version.Build, 5);
            n = NuGetv2.Grammar.NuGetv2Version.Parse("3.4.0199");

            //Assert.Throws<ParseException>(() => NuGetv2.Grammar.NuGetv2Version.Parse("A.2.3"));
            //Assert.Throws<ParseException>(() => NuGetv2.Grammar.NuGetv2Version.Parse("3.2.3.X"));
        }
Exemple #3
0
        public void CanCompare()
        {
            NuGetv2 v0  = new NuGetv2("0.7");
            NuGetv2 v1  = new NuGetv2("2.3");
            NuGetv2 v2  = new NuGetv2("2.4");
            NuGetv2 v3  = new NuGetv2("2.4.4");
            NuGetv2 v4  = new NuGetv2("3.3.3.4");
            NuGetv2 v4b = new NuGetv2("3.3.3.5");

            Assert.True(v2 > v1);
            Assert.True(v4b > v4);
            Assert.True(v4 < v4b);
            Assert.Equal(v0, NuGetv2.Parse("0.7.0"));
            Assert.True(v3 > v2);
            Assert.True(v1 < v4);
            Assert.True(v090b2 > v090a1);
            Assert.True(v090a1 < v090b2);
        }