Exemple #1
0
        public void VersionSortTest2()
        {
            SemanticVersion[] versions = new SemanticVersion[] {
                SemanticVersion.Parse("1.2.3-rc"),
                SemanticVersion.Parse("1.2.2"),
                SemanticVersion.Parse("1.2.3-beta.10.2"),
                SemanticVersion.Parse("1.2.3-beta"),
                SemanticVersion.Parse("1.2.3-beta-beta"),
                SemanticVersion.Parse("1.2.3-beta.2"),
                SemanticVersion.Parse("1.2.3-beta.12+1.2.3.4"),
                SemanticVersion.Parse("1.2.3-beta.10+1.2.3.4"),
                SemanticVersion.Parse("1.2.3+testing"),
            };

            var order = versions.OrderByDescending(x => x).ToList();

            Assert.AreEqual("1.2.3+testing", order[0].ToString());
            Assert.AreEqual("1.2.3-rc", order[1].ToString());
            Assert.AreEqual("1.2.3-beta-beta", order[2].ToString());
            Assert.AreEqual("1.2.3-beta.12+1.2.3.4", order[3].ToString());
            Assert.AreEqual("1.2.3-beta.10.2", order[4].ToString());
            Assert.AreEqual("1.2.3-beta.10+1.2.3.4", order[5].ToString());
            Assert.AreEqual("1.2.3-beta.2", order[6].ToString());
            Assert.AreEqual("1.2.3-beta", order[7].ToString());
            Assert.AreEqual("1.2.2", order[8].ToString());
        }
Exemple #2
0
        public void VersionSortTest()
        {
            SemanticVersion[] versions = new SemanticVersion[] {
                new SemanticVersion(1, 0, 0, null, null),
                new SemanticVersion(0, 0, 0, null, null),
                new SemanticVersion(3, 0, 0, null, null)
            };

            Assert.AreEqual(0, versions.OrderBy(x => x).FirstOrDefault().Major);
            Assert.AreEqual(3, versions.OrderByDescending(x => x).FirstOrDefault().Major);
        }
Exemple #3
0
        public void MetadataDoesNotInfluencePrecedence()
        {
            var versions = new SemanticVersion[]
            {
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("2")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("1")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("3")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("b")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("a")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("c")),
                new SemanticVersion(1, 0, 0, null, metadata: new VersionMetadata("c.1")),
            };

            Assert.Equal(versions, versions.OrderByDescending(x => x));
            Assert.Equal(versions, versions.OrderBy(x => x));
        }
Exemple #4
0
        public void SortVersions()
        {
            var versions = new SemanticVersion[] {
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("alpha")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("alpha.1")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("alpha.beta")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("beta")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("beta.2")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("beta.11")),
                new SemanticVersion(1, 0, 0, new PreReleaseIdentifier("rc.1")),
                new SemanticVersion(1, 0, 0, null),
                new SemanticVersion(2, 0, 0, null),
                new SemanticVersion(2, 1, 0, null),
                new SemanticVersion(2, 1, 2, null),
                new SemanticVersion(2, 1, 11, null),
                new SemanticVersion(2, 2, 0, null),
                new SemanticVersion(2, 11, 0, null),
            };
            var sortedVersions = versions.OrderByDescending(x => x).OrderBy(x => x).ToArray();

            Assert.Equal(versions, sortedVersions);
        }