public void InEqualityTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 4, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA != testVersionB); }
public void GreaterMinorTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 3, Build = 3, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA > testVersionB); }
public void GreaterThanEqualTo_Equal() { Versioning.Version testVersionA = new Version() { Major = 2, Minor = 2, Build = 2, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 2, Description = "hello world" }; Assert.IsTrue(testVersionA >= testVersionB); }
public void Equality_by_smaller_build() { Versioning.Version leftSide = new Version() { Major = 1, Minor = 3, Build = 0, Description = "Good bye world" }; Versioning.Version rightSide = new Version() { Major = 1, Minor = 2, Build = 2, Description = "hello world" }; Assert.IsTrue(leftSide > rightSide); }
public void InEqualityTest_WidthDate() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 4, Description = "Good bye world", DateTime = new DateTime(2012, 12, 1) }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world", DateTime = new DateTime(2012, 12, 1) }; Assert.IsTrue(testVersionA != testVersionB); }
public void LessThanRevisionTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 2, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA < testVersionB); }
public void SimpleVersion_LargeDigits() { Versioning.Version testVersion = new Version() { Major = 1664, Minor = 534646542, Build = 32555654, Description = null }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }
public void SimpleVersion_NoDescription() { Versioning.Version testVersion = new Version() { Major = 1, Minor = 2, Build = 3, Description = null }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }
public void ReallyLogDescription() { Versioning.Version testVersion = new Version() { Major = 1, Minor = 2, Build = 3, Description = "Really long description Really long description Really long description Really long description Really long description Really long description" }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }
public void LessThanMajorTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 3, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 2, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA < testVersionB); }
public void SimpleVersion_LargeDigits() { Versioning.Version testVersion = new Version() { Major = 1664, Minor = 534646542, Build = 32555654, Description = null }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }
public void InEqualityTest_WidthDate() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 4, Description = "Good bye world", DateTime = new DateTime(2012, 12, 1) }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world", DateTime = new DateTime(2012, 12, 1) }; Assert.IsTrue(testVersionA != testVersionB); }
public void InEqualityTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 4, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA != testVersionB); }
public void GreaterThanEqualTo_Greater() { Versioning.Version testVersionA = new Version() { Major = 2, Minor = 2, Build = 2, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 2, Description = "hello world" }; Assert.IsTrue(testVersionA >= testVersionB); }
public void GreaterRevisionTest() { Versioning.Version testVersionA = new Version() { Major = 1, Minor = 2, Build = 4, Description = "Good bye world" }; Versioning.Version testVersionB = new Version() { Major = 1, Minor = 2, Build = 3, Description = "hello world" }; Assert.IsTrue(testVersionA > testVersionB); }
public void Equality_by_smaller_build() { Versioning.Version leftSide = new Version() { Major = 1, Minor = 3, Build = 0, Description = "Good bye world" }; Versioning.Version rightSide = new Version() { Major = 1, Minor = 2, Build = 2, Description = "hello world" }; Assert.IsTrue(leftSide > rightSide); }
public void SimpleVersion_NoDescription() { Versioning.Version testVersion = new Version() { Major = 1, Minor = 2, Build = 3, Description = null }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }
public static string[] Build(Arguments.IBuildArguments buildArguments, Logging.ILog log = null) { if (log == null) { log = new Logging.NoLogging(); } if (string.IsNullOrEmpty(buildArguments.ScriptPath)) { buildArguments.ScriptPath = System.Environment.CurrentDirectory; } if (string.IsNullOrEmpty(buildArguments.DbProviderFactory)) { buildArguments.DbProviderFactory = "System.Data.SqlClient"; } if (string.IsNullOrEmpty(buildArguments.ScriptProcessor)) { buildArguments.ScriptProcessor = typeof(SqlScriptRunner.ScriptProcessing.SqlServerScriptProcessor).FullName; } if (string.IsNullOrEmpty(buildArguments.VersionParser)) { buildArguments.VersionParser = typeof(SqlScriptRunner.Versioning.VersionDateParser).AssemblyQualifiedName; } Type t = Type.GetType(buildArguments.VersionParser); SqlScriptRunner.Versioning.IParseVersions versionParser = (Activator.CreateInstance(t) as SqlScriptRunner.Versioning.IParseVersions); SqlScriptRunner.Versioning.Version minVersion = null; SqlScriptRunner.Versioning.Version maxVersion = null; if (string.IsNullOrEmpty(buildArguments.MinimumVersion)) { minVersion = SqlScriptRunner.Versioning.Version.Min; } else { minVersion = versionParser.Parse(buildArguments.MinimumVersion); } if (string.IsNullOrEmpty(buildArguments.MaximumVersion)) { maxVersion = SqlScriptRunner.Versioning.Version.Max; } else { maxVersion = versionParser.Parse(buildArguments.MaximumVersion); } log.Info("--------------------------------"); log.Info(string.Format("Min:{0}, Max:{1}, ScriptPath:{2}, Transactional:{4}, DryRun:{5}\r\nConnectionString:{3}", minVersion, maxVersion, buildArguments.ScriptPath, buildArguments.ConnectionString, buildArguments.Transactional, buildArguments.DryRun)); log.Info("--------------------------------"); DbConnection connection = null; if (!buildArguments.DryRun) { //make sure we can connect to the database DbProviderFactory factory = DbProviderFactories.GetFactory(buildArguments.DbProviderFactory); connection = factory.CreateConnection(); if (connection == null) { throw new ArgumentException( "Could not create a connection to the database, via the Provider Factory:" + buildArguments.DbProviderFactory); } else { connection.ConnectionString = buildArguments.ConnectionString; connection.Open(); } } SortedList <string, string> Files = SqlScriptRunner.ScriptRunner.ResolveScriptsFromPathAndVersion(buildArguments.ScriptPath, buildArguments.ScriptPattern, buildArguments.Recurse, System.Environment.CurrentDirectory, minVersion, maxVersion, versionParser); log.Info(string.Format("Resolved:{0} files.", Files.Count)); foreach (var file in Files.Keys) { log.Info(file); if (!buildArguments.DryRun) { try { log.Info("Executing"); string script = System.IO.File.ReadAllText(Files[file]); SqlScriptRunner.ScriptRunner runner = new ScriptRunner(script, null); if (buildArguments.Transactional) { if (connection.State == ConnectionState.Closed) { connection.Open(); } System.Data.IDbTransaction transaction = null; if (buildArguments.Transactional) { transaction = connection.BeginTransaction(); } try { runner.Execute(connection, transaction); if (buildArguments.Transactional) { transaction.Commit(); } log.Info("Success:" + file); } catch (Exception e) { log.Info("Fail [In Trx:" + buildArguments.Transactional + "]:" + file); log.Fatal(e); if (buildArguments.Transactional) { transaction.Rollback(); } throw; } } else { runner.Execute(connection); } } catch (Exception e) { if (buildArguments.BreakOnError) { throw; } else { log.Debug("There was an error with a script, since BreakOnError is false, we will continue.File:" + file, e); } } } } log.Info("Done Executing"); return((from f in Files select f.Value).ToArray()); }
public void ReallyLogDescription() { Versioning.Version testVersion = new Version() { Major = 1, Minor = 2, Build = 3, Description = "Really long description Really long description Really long description Really long description Really long description Really long description" }; var input = string.Format("{0}.{1}.{2} {3}", testVersion.Major, testVersion.Minor, testVersion.Build, testVersion.Description); Assert.IsTrue(ParseAndValidate(input, testVersion, null)); }