Ejemplo n.º 1
0
        // All possible ways to parse a version from a string
        private static List <SemanticVersion> Parse(string version)
        {
            // Parse
            var versions = new List <SemanticVersion>();

            versions.Add(SemanticVersion.Parse(version));

            // TryParse
            SemanticVersion nuVer = null;

            SemanticVersion.TryParse(version, out nuVer);
            versions.Add(nuVer);

            // TryParseStrict
            nuVer = null;
            SemanticVersion.TryParseStrict(version, out nuVer);
            versions.Add(nuVer);

            // Constructors
            var normal = SemanticVersion.Parse(version);

            versions.Add(normal);
            versions.Add(new SemanticVersion(SemanticVersion.Parse(version)));

            return(versions);
        }
Ejemplo n.º 2
0
        public void SemVerVersionValidReleaseLabels(string versionString)
        {
            // Arrange & act
            SemanticVersion semVer = null;
            var             valid  = SemanticVersion.TryParseStrict(versionString, out semVer);

            // Assert
            Assert.True(valid);
        }
Ejemplo n.º 3
0
        public void SemVerVersionLeadingZeros(string versionString)
        {
            // Arrange & act
            SemanticVersion semVer = null;
            var             valid  = SemanticVersion.TryParseStrict(versionString, out semVer);

            // Assert
            Assert.False(valid);
        }
Ejemplo n.º 4
0
        public void SemVerVersionMustBe3Parts(string version, bool expected)
        {
            // Arrange & act
            SemanticVersion semVer = null;
            var             valid  = SemanticVersion.TryParseStrict(version, out semVer);

            // Assert
            Assert.Equal(expected, valid);
        }
Ejemplo n.º 5
0
        public void SemVerVersionMetadataNonEmptyParts(string versionString)
        {
            // Arrange & act
            SemanticVersion semVer = null;
            var             valid  = SemanticVersion.TryParseStrict(versionString, out semVer);

            // Assert
            Assert.False(valid);
        }
Ejemplo n.º 6
0
        public void SemVerVersionMetadataOrder(string versionString)
        {
            // Arrange & act
            SemanticVersion semVer = null;
            var             valid  = SemanticVersion.TryParseStrict(versionString, out semVer);

            // Assert
            Assert.True(valid);
            Assert.True(string.IsNullOrEmpty(semVer.SpecialVersion));
        }
        public IEnumerable <PackageIssue> Validate(IPackage package)
        {
            SemanticVersion semVer;

            if (!SemanticVersion.TryParseStrict(package.Version.ToString(), out semVer))
            {
                yield return(new PackageIssue(LocalizedResourceManager.GetString("Warning_SemanticVersionTitle"),
                                              String.Format(CultureInfo.CurrentCulture, LocalizedResourceManager.GetString("Warning_SemanticVersion"), package.Version),
                                              LocalizedResourceManager.GetString("Warning_SemanticVersionSolution")));
            }
        }
Ejemplo n.º 8
0
        public void SemVerSortIgnoreReleaseCasing(string a, string b)
        {
            // Arrange & act
            SemanticVersion semVerA = null, semVerB = null;

            SemanticVersion.TryParseStrict(a, out semVerA);
            SemanticVersion.TryParseStrict(b, out semVerB);

            // Assert
            Assert.True(semVerA == semVerB);
        }
Ejemplo n.º 9
0
        public void SemVerSortReleaseLabelCount(string lower, string higher)
        {
            // Arrange & act
            SemanticVersion lowerSemVer = null, higherSemVer = null;

            SemanticVersion.TryParseStrict(lower, out lowerSemVer);
            SemanticVersion.TryParseStrict(higher, out higherSemVer);

            // Assert
            Assert.True(lowerSemVer < higherSemVer);
        }
Ejemplo n.º 10
0
        public void SemVerSortNumericAlpha(string lower, string higher)
        {
            // Arrange & act
            SemanticVersion lowerSemVer = null, higherSemVer = null;

            SemanticVersion.TryParseStrict(lower, out lowerSemVer);
            SemanticVersion.TryParseStrict(higher, out higherSemVer);

            // Assert
            Assert.True(lowerSemVer < higherSemVer);
        }
Ejemplo n.º 11
0
        public IEnumerable <PackageIssue> Validate(IPackage package)
        {
            SemanticVersion semVer;

            if (!SemanticVersion.TryParseStrict(package.Version.ToString(), out semVer))
            {
                yield return(new PackageIssue(NuGetResources.Warning_SemanticVersionTitle,
                                              String.Format(CultureInfo.CurrentCulture, NuGetResources.Warning_SemanticVersion, package.Version),
                                              NuGetResources.Warning_SemanticVersionSolution));
            }
        }