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));
 }
Example #2
0
 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();
     }
 }
Example #3
0
 public string BuildInsertScript(Migration migration)
 {
     return string.Format("INSERT INTO Migrations(Id) VALUES({0})", migration.Id);
 }
Example #4
0
 public string BuildDeleteScript(Migration migration)
 {
     return string.Format("DELETE Migrations WHERE Id = {0}", migration.Id);
 }
Example #5
0
 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;
     }
 }
Example #6
0
 public string BuildInsertScript(Migration migration)
 {
     return BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")");
 }
Example #7
0
 public string BuildDeleteScript(Migration migration)
 {
     return BuildSqlScript("DELETE [", _migrationsTableName, "] WHERE Id = ", migration.Id);
 }
Example #8
0
 public string BuildInsertScript(Migration migration)
 {
     return(BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")"));
 }
Example #9
0
 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, ""));
 }