Exemplo n.º 1
0
        public void CanParseVersion()
        {
            var version = "1.2.3.4-a.b.c.d.5.+abc123";

            using var parsedVersion = VerUtil.ParseVersion(version, strict: false);
            Assert.Equal(version, parsedVersion.Version);
            Assert.Equal(1u, parsedVersion.Major);
            Assert.Equal(2u, parsedVersion.Minor);
            Assert.Equal(3u, parsedVersion.Patch);
            Assert.Equal(4u, parsedVersion.Revision);
            Assert.Equal(5, parsedVersion.ReleaseLabels.Length);
            Assert.Equal("+abc123", parsedVersion.Metadata);
            Assert.True(parsedVersion.IsInvalid);

            Assert.Equal("a", parsedVersion.ReleaseLabels[0].Label);
            Assert.False(parsedVersion.ReleaseLabels[0].IsNumeric);

            Assert.Equal("b", parsedVersion.ReleaseLabels[1].Label);
            Assert.False(parsedVersion.ReleaseLabels[1].IsNumeric);

            Assert.Equal("c", parsedVersion.ReleaseLabels[2].Label);
            Assert.False(parsedVersion.ReleaseLabels[2].IsNumeric);

            Assert.Equal("d", parsedVersion.ReleaseLabels[3].Label);
            Assert.False(parsedVersion.ReleaseLabels[3].IsNumeric);

            Assert.Equal("5", parsedVersion.ReleaseLabels[4].Label);
            Assert.True(parsedVersion.ReleaseLabels[4].IsNumeric);
            Assert.Equal(5u, parsedVersion.ReleaseLabels[4].Value);
        }
Exemplo n.º 2
0
        public void CanCopyVersion()
        {
            var version = "1.2.3.4-5.6.7.8.9.0";

            VerUtilVersion copiedVersion = null;

            try
            {
                using (var parsedVersion = VerUtil.ParseVersion(version, strict: true))
                {
                    copiedVersion = VerUtil.CopyVersion(parsedVersion);
                }

                using (var secondVersion = VerUtil.ParseVersion(version, strict: true))
                {
                    Assert.Equal(0, VerUtil.CompareParsedVersions(copiedVersion, secondVersion));
                }
            }
            finally
            {
                copiedVersion?.Dispose();
            }
        }