public void EqualsTest()
 {
     ScriptVersionNumber a = new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta);
     Assert.IsTrue(a.Equals(new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta)));
     Assert.IsFalse(a.Equals(new ScriptVersionNumber()));
     Assert.IsFalse(a.Equals(new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta)));
     Assert.IsFalse(a.Equals(new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Release)));
     Assert.IsFalse(a.Equals(2));
     Assert.IsFalse(a.Equals("2.3.6 beta"));
 }
Ejemplo n.º 2
0
        public void LatestVersionTest()
        {
            ScriptVersionNumber expectedVersion = new ScriptVersionNumber(2, 0, 96, ScriptReleaseStage.Release);
            Assert.AreEqual(expectedVersion, manifest.LatestVersion.VersionNumber, "Latest version");

            expectedVersion = new ScriptVersionNumber(3, 0, 0);
            manifest.Versions.Add(new ScriptVersion(expectedVersion));
            Assert.AreEqual(expectedVersion, manifest.LatestVersion.VersionNumber, "Added latest version");

            expectedVersion.Major = 1;
            Assert.AreNotEqual(expectedVersion, manifest.LatestVersion, "Changed version so that it no longer is the latest version.");

            ScriptManifest m = new ScriptManifest();
            Assert.AreEqual(0, m.Versions.Count, "Version count should be 0.");
            Assert.AreEqual(null, m.LatestVersion, "LatestVersion in empty manifest should be null");
        }
Ejemplo n.º 3
0
        public void LatestStableVersionTest()
        {
            ScriptVersionNumber expectedVersion = new ScriptVersionNumber(2, 0, 96, ScriptReleaseStage.Release);
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 1");

            manifest.Versions.Add(new ScriptVersion(new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Alpha)));
            manifest.Versions.Add(new ScriptVersion(new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Beta)));
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 2");

            expectedVersion = new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Release);
            manifest.Versions.Add(new ScriptVersion(expectedVersion));
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 3");

            ScriptManifest m = new ScriptManifest();
            Assert.AreEqual(0, m.Versions.Count, "Version count should be 0.");
            Assert.AreEqual(null, m.LatestStableVersion, "LatestStableVersion in empty manifest should be null");
        }
        public void CompareToTest()
        {
            ScriptVersionNumber a = new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta);

            Assert.AreEqual(0, a.CompareTo(new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta)));
            Assert.AreEqual(1, a.CompareTo(new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta)));
            Assert.AreEqual(-1, a.CompareTo(new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta)));

            Assert.AreEqual(1, a.CompareTo(new ScriptVersionNumber(2, 2, 6, ScriptReleaseStage.Beta)));
            Assert.AreEqual(-1, a.CompareTo(new ScriptVersionNumber(2, 4, 6, ScriptReleaseStage.Beta)));

            Assert.AreEqual(1, a.CompareTo(new ScriptVersionNumber(2, 3, 5, ScriptReleaseStage.Beta)));
            Assert.AreEqual(-1, a.CompareTo(new ScriptVersionNumber(2, 3, 7, ScriptReleaseStage.Beta)));

            Assert.AreEqual(1, a.CompareTo(new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Alpha)));
            Assert.AreEqual(-1, a.CompareTo(new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Release)));
        }
        public void FromStringTest()
        {
            ScriptVersionNumber version = new ScriptVersionNumber("2.5.3 alpha");
            Assert.AreEqual(version.Major, 2);
            Assert.AreEqual(version.Minor, 5);
            Assert.AreEqual(version.Revision, 3);
            Assert.AreEqual(version.ReleaseStage, ScriptReleaseStage.Alpha);

            version = new ScriptVersionNumber("2.5.3 beta");
            Assert.AreEqual(version.Major, 2);
            Assert.AreEqual(version.Minor, 5);
            Assert.AreEqual(version.Revision, 3);
            Assert.AreEqual(version.ReleaseStage, ScriptReleaseStage.Beta);

            version = new ScriptVersionNumber("2.5.3");
            Assert.AreEqual(version.Major, 2);
            Assert.AreEqual(version.Minor, 5);
            Assert.AreEqual(version.Revision, 3);
            Assert.AreEqual(version.ReleaseStage, ScriptReleaseStage.Release);

            version = new ScriptVersionNumber("2.5.3 release");
            Assert.AreEqual(version.Major, 2);
            Assert.AreEqual(version.Minor, 5);
            Assert.AreEqual(version.Revision, 3);
            Assert.AreEqual(version.ReleaseStage, ScriptReleaseStage.Release);

            version = new ScriptVersionNumber("2");
            Assert.AreEqual(version.Major, 2);

            version = new ScriptVersionNumber("2.5");
            Assert.AreEqual(version.Major, 2);
            Assert.AreEqual(version.Minor, 5);

            try
            {
                version = new ScriptVersionNumber("2..something");
                Assert.Fail("Supplying incorrect version string should throw exception.");
            }
            catch (ArgumentException e)
            {
                Assert.IsNotNull(e); //I don't think this will ever fail, but still..
            }
        }
        public void OperatorsTest()
        {
            ScriptVersionNumber a = new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta);

            //Smaller than operator.
            Assert.IsTrue(a < new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a < new ScriptVersionNumber(2, 4, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a < new ScriptVersionNumber(2, 3, 7, ScriptReleaseStage.Beta));
            Assert.IsTrue(a < new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Release));
            Assert.IsFalse(a < new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a < new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));

            //Smaller than / equals operator.
            Assert.IsTrue(a <= new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a <= new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a <= new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));

            //Larger than operator.
            Assert.IsTrue(a > new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a > new ScriptVersionNumber(2, 2, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a > new ScriptVersionNumber(2, 3, 5, ScriptReleaseStage.Beta));
            Assert.IsTrue(a > new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Alpha));
            Assert.IsFalse(a > new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a > new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta));

            //Larger than / equals operator.
            Assert.IsTrue(a >= new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsTrue(a >= new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a >= new ScriptVersionNumber(3, 3, 6, ScriptReleaseStage.Beta));

            //Equality operator.
            Assert.IsTrue(a == new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a == new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));

            //Inequality operator.
            Assert.IsTrue(a != new ScriptVersionNumber(1, 3, 6, ScriptReleaseStage.Beta));
            Assert.IsFalse(a != new ScriptVersionNumber(2, 3, 6, ScriptReleaseStage.Beta));
        }
        public void ToStringUnderscoresTest()
        {
            ScriptVersionNumber version = new ScriptVersionNumber(2, 5, 3);
            version.ReleaseStage = ScriptReleaseStage.Alpha;
            Assert.AreEqual("2_5_3_alpha", version.ToString(true));

            version.ReleaseStage = ScriptReleaseStage.Beta;
            Assert.AreEqual("2_5_3_beta", version.ToString(true));

            version.ReleaseStage = ScriptReleaseStage.Release;
            Assert.AreEqual("2_5_3", version.ToString(true));
        }
        public void ToStringTest()
        {
            ScriptVersionNumber version = new ScriptVersionNumber(2, 5, 3);
            version.ReleaseStage = ScriptReleaseStage.Alpha;
            Assert.AreEqual("2.5.3 alpha", version.ToString());

            version.ReleaseStage = ScriptReleaseStage.Beta;
            Assert.AreEqual("2.5.3 beta", version.ToString());

            version.ReleaseStage = ScriptReleaseStage.Release;
            Assert.AreEqual("2.5.3", version.ToString());
        }