public override int Compare(object x, object y)
            {
                ClassicVersion left  = x as ClassicVersion;
                ClassicVersion right = y as ClassicVersion;

                return(left.SystemVersion.CompareTo(right.SystemVersion));
            }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            ClassicVersion version = obj as ClassicVersion;

            if (object.ReferenceEquals(version, null))
            {
                return(false);
            }

            return(this.SystemVersion.Equals(version.SystemVersion));
        }
        /// <summary>
        /// Inserts the specified version into the version table.
        /// </summary>
        /// <param name="version">The version to insert.</param>
        /// <param name="session">The database connection.</param>
        public void InsertVersion(VersionBase version, ISession session)
        {
            ClassicVersion classicVersion = version as ClassicVersion;

            if (!classicVersion.CreatedOn.HasValue)
            {
                classicVersion.CreatedOn = DateTime.UtcNow;
            }
            classicVersion.UpdatedOn = DateTime.UtcNow;
            session.SaveOrUpdate(version);
        }
        /// <summary>
        /// Returns whether a script belongs to the current version and if so whether it has already been executed
        /// </summary>
        /// <param name="currentVersion"></param>
        /// <param name="targetVersion"></param>
        /// <param name="task"></param>
        /// <returns></returns>
        public bool HasExecutedScript(VersionBase currentVersion, VersionBase targetVersion, IDatabaseTask task)
        {
            if (currentVersion != null)
            {
                ClassicVersion currentClassicVersion = currentVersion as ClassicVersion;
                ClassicVersion targetClassicVersion  = targetVersion as ClassicVersion;
                if (currentClassicVersion.SystemVersion.Equals(targetClassicVersion.SystemVersion))
                {
                    return(currentClassicVersion.HasExecutedTask(task));
                }
            }

            return(false);
        }
        public void ShouldOrderVersionsBasedOnSystemVersion()
        {
            // Arrange
            ClassicVersionProvider provider = new ClassicVersionProvider();
            var comparer = provider.GetComparer();

            var version1 = new ClassicVersion("4.9");
            var version2 = new ClassicVersion("4.10");

            // Act
            var result = comparer.Compare(version1, version2);

            // Assert
            Assert.True(result < 0, "The versions were not ordered correctly");
        }
Beispiel #6
0
 public ClassicVersionTask(ClassicVersion version, string scriptName)
     : base(scriptName)
 {
     this.Version = version;
 }