public void compare_x_less_then_y(string x,string y) { var migrationA = new Migration {Number = x}; var migrationB = new Migration {Number = y}; var comparer = new NumberComparer(); Assert.AreEqual(-1, comparer.Compare(migrationA, migrationB)); }
public bool IsMigrationPending(Migration migration) { var conn = new SqlConnection(_connstr); conn.Open(); try { IDbCommand cmd = conn.CreateCommand(); cmd.CommandText = string.Format("SELECT COUNT(*) FROM Migrations WHERE Id = {0}", migration.Id); return (int)cmd.ExecuteScalar() < 1; } finally { conn.Close(); } }
public string BuildInsertScript(Migration migration) { return string.Format("INSERT INTO Migrations(Id) VALUES({0})", migration.Id); }
public string BuildDeleteScript(Migration migration) { return string.Format("DELETE Migrations WHERE Id = {0}", migration.Id); }
public bool IsMigrationPending(Migration migration) { using (var conn = OpenConnectionAndChangeDb()) { IDbCommand cmd = conn.CreateCommand(); cmd.CommandText = string.Concat("SELECT COUNT(*) FROM [", _migrationsTableName, "] WHERE Id = ", migration.Id); return (int)cmd.ExecuteScalar() < 1; } }
public string BuildInsertScript(Migration migration) { return BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")"); }
public string BuildDeleteScript(Migration migration) { return BuildSqlScript("DELETE [", _migrationsTableName, "] WHERE Id = ", migration.Id); }
public string BuildInsertScript(Migration migration) { return(BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")")); }
public string BuildDeleteScript(Migration migration) { return(BuildSqlScript("DELETE [", _migrationsTableName, "] WHERE Id = ", migration.Id)); }
public void InvalidFormatX() { var migrationA = new Migration { Number = "ABC" }; var migrationB = new Migration { Number = "111" }; var comparer = new NumberComparer(); Assert.Throws<FormatException>(() => Assert.AreNotEqual(0, comparer.Compare(migrationA, migrationB))); }
public void compare_x_not_greater_then_version_y_lesser(string x, string y) { var migrationA = new Migration { Number = x }; var comparer = new NumberComparer(); Assert.AreEqual(false, comparer.IsMigrationAfterVersion(migrationA, y)); }
public void VersionIsNullOrEmpty() { var migrationA = new Migration { Number = "111" }; var comparer = new NumberComparer(); Assert.AreEqual(true, comparer.IsMigrationAfterVersion(migrationA, null)); Assert.AreEqual(true, comparer.IsMigrationAfterVersion(migrationA, "")); }