Пример #1
0
 public void Test_Constructor_WhenInts()
 {
     var version = new Version(5, 4, 3, 2);
     Assert.AreEqual(5, version.Major);
     Assert.AreEqual(4, version.Minor);
     Assert.AreEqual(3, version.Build);
     Assert.AreEqual(2, version.Revision);
 }
Пример #2
0
 public void Test_Constructor_WhenGoodString()
 {
     var version = new Version("10.2.1.5");
     Assert.AreEqual(10, version.Major);
     Assert.AreEqual(2, version.Minor);
     Assert.AreEqual(1, version.Build);
     Assert.AreEqual(5, version.Revision);
 }
Пример #3
0
 public void Test_Constructor_WhenEmptyString()
 {
     try
     {
         var version = new Version(string.Empty);
         Assert.Fail();
     }
     catch (ArgumentException)
     {
     }
     catch
     {
         Assert.Fail();
     }
 }
Пример #4
0
 public void Test_Constructor_WhenBuildNotAnInteger()
 {
     try
     {
         var version = new Version("10.1.v.5");
         Assert.Fail();
     }
     catch (ArgumentException)
     {
     }
     catch
     {
         Assert.Fail();
     }
 }
Пример #5
0
        /// <summary>
        /// Confirms the current version of the database matches the specified version.
        /// </summary>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="version">The version.</param>
        /// <param name="confirmed">if set to <c>true</c>, the database version has been confirmed.</param>
        /// <returns></returns>
        public override bool GetVersion(string databaseName, out Domain.Values.Version currentVersion)
        {
            currentVersion = null;

            try
            {
                var database = _server.Databases[databaseName];
                if (null == database)
                {
                    log.ErrorFormat("There is no database called '{0}' on the server.", databaseName);
                    return false;
                }

                var currentDatabaseVersion = new Domain.Values.Version(database.ExtendedProperties["SCHEMA_VERSION"].Value as string);
                log.InfoFormat(CultureInfo.InvariantCulture, "Current database version is {0}", currentDatabaseVersion);
                currentVersion = currentDatabaseVersion;
            }
            catch (ExecutionFailureException efeEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", efeEx);
                return false;
            }
            catch (SmoException smoEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", smoEx);
                return false;
            }

            return true;
        }
Пример #6
0
        public void Test_LessThanOrEqualToOperator()
        {
            var version1 = new Version(2, 3, 4, 5);

            //revision is greater
            var version2 = new Version(2, 3, 4, 6);
            Assert.IsFalse(version2 <= version1);

            //build is greater
            version2 = new Version(2, 3, 5, 4);
            Assert.IsFalse(version2 <= version1);

            //minor is greater
            version2 = new Version(2, 4, 1, 1);
            Assert.IsFalse(version2 <= version1);

            //major is greater
            version2 = new Version(3, 1, 1, 1);
            Assert.IsFalse(version2 <= version1);

            //equal
            version2 = new Version(2, 3, 4, 5);
            Assert.IsTrue(version2 <= version1);

            //revision is less
            version2 = new Version(2, 3, 4, 3);
            Assert.IsTrue(version2 <= version1);

            //build is less
            version2 = new Version(2, 3, 3, 5);
            Assert.IsTrue(version2 <= version1);

            //minor is less
            version2 = new Version(2, 2, 5, 5);
            Assert.IsTrue(version2 <= version1);

            //major is less
            version2 = new Version(1, 4, 5, 5);
            Assert.IsTrue(version2 <= version1);
        }
Пример #7
0
        public void Test_InequalityOperator()
        {
            var version1 = new Version(2, 3, 4, 5);

            //revision is greater
            var version2 = new Version(2, 3, 4, 6);
            Assert.IsTrue(version2 != version1);

            //build is greater
            version2 = new Version(2, 3, 5, 5);
            Assert.IsTrue(version2 != version1);

            //minor is greater
            version2 = new Version(2, 4, 1, 1);
            Assert.IsTrue(version2 != version1);

            //major is greater
            version2 = new Version(3, 1, 1, 1);
            Assert.IsTrue(version2 != version1);

            //equal
            version2 = new Version(2, 3, 4, 5);
            Assert.IsFalse(version2 != version1);

            //revision is less
            version2 = new Version(2, 3, 4, 3);
            Assert.IsTrue(version2 != version1);

            //build is less
            version2 = new Version(2, 3, 3, 5);
            Assert.IsTrue(version2 != version1);

            //minor is less
            version2 = new Version(2, 2, 5, 5);
            Assert.IsTrue(version2 != version1);

            //major is less
            version2 = new Version(1, 4, 5, 5);
            Assert.IsTrue(version2 != version1);

            //both null
            Assert.IsFalse((Version)null != (Version)null);

            //lhs null
            Assert.IsTrue((Version)null != version1);

            //rhs null
            Assert.IsTrue(version2 != (Version)null);
        }
Пример #8
0
        public void Test_GreaterThanOperator()
        {
            var version1 = new Version(2, 3, 4, 1);

            //revision is greater
            var version2 = new Version(2, 3, 4, 2);
            Assert.IsTrue(version2 > version1);

            //build is greater
            version2 = new Version(2, 3, 5, 1);
            Assert.IsTrue(version2 > version1);

            //minor is greater
            version2 = new Version(2, 4, 1, 0);
            Assert.IsTrue(version2 > version1);

            //major is greater
            version2 = new Version(3, 1, 1, 0);
            Assert.IsTrue(version2 > version1);

            //equal
            version2 = new Version(2, 3, 4, 1);
            Assert.IsFalse(version2 > version1);

            //revision is less
            version2 = new Version(2, 3, 4, 0);
            Assert.IsFalse(version2 > version1);

            //build is less
            version2 = new Version(2, 3, 2, 4);
            Assert.IsFalse(version2 > version1);

            //minor is less
            version2 = new Version(2, 2, 5, 5);
            Assert.IsFalse(version2 > version1);

            //major is less
            version2 = new Version(1, 4, 5, 5);
            Assert.IsFalse(version2 > version1);
        }
Пример #9
0
 public void Test_Constructor_WhenStringIsTooShort()
 {
     try
     {
         var version = new Version("1.5.4");
         Assert.Fail();
     }
     catch (ArgumentException)
     {
     }
     catch
     {
         Assert.Fail();
     }
 }