Esempio n. 1
0
        public void ValidVersion(
            string expectedSemVer,
            string expectedWindowsFileVersion,
            string expectedCFBundleVersion,
            string expectedCFBundleShortVersionString)
        {
            ReleaseVersion version;

            // parse and assert the semver format
            ReleaseVersion.TryParse(expectedSemVer, out version).ShouldBeTrue();
            version.ToString().ShouldEqual(expectedSemVer);

            // parse and assert the windows file version format
            var windowsFileVersion = version.ToWindowsFileVersion();

            windowsFileVersion.ToString().ShouldEqual(expectedWindowsFileVersion);
            version.WithBuild(0).ShouldEqual(ReleaseVersion.FromWindowsFileVersion(windowsFileVersion));

            if (expectedCFBundleVersion == null)
            {
                Assert.Throws <FormatException> (
                    () => version.ToString(ReleaseVersionFormat.AppleCFBundleVersion));
            }
            else
            {
                version.ToString(ReleaseVersionFormat.AppleCFBundleVersion)
                .ShouldEqual(expectedCFBundleVersion);
            }

            if (expectedCFBundleShortVersionString == null)
            {
                Assert.Throws <FormatException> (
                    () => version.ToString(ReleaseVersionFormat.AppleCFBundleShortVersion));
            }
            else
            {
                version.ToString(ReleaseVersionFormat.AppleCFBundleShortVersion)
                .ShouldEqual(expectedCFBundleShortVersionString);
            }
        }