Exemplo n.º 1
0
 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));
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 3
0
 public string BuildInsertScript(Migration migration)
 {
     return string.Format("INSERT INTO Migrations(Id) VALUES({0})", migration.Id);
 }
Exemplo n.º 4
0
 public string BuildDeleteScript(Migration migration)
 {
     return string.Format("DELETE Migrations WHERE Id = {0}", migration.Id);
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 6
0
 public string BuildInsertScript(Migration migration)
 {
     return BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")");
 }
Exemplo n.º 7
0
 public string BuildDeleteScript(Migration migration)
 {
     return BuildSqlScript("DELETE [", _migrationsTableName, "] WHERE Id = ", migration.Id);
 }
Exemplo n.º 8
0
 public string BuildInsertScript(Migration migration)
 {
     return(BuildSqlScript("INSERT INTO [", _migrationsTableName, "](Id) VALUES(", migration.Id, ")"));
 }
Exemplo n.º 9
0
 public string BuildDeleteScript(Migration migration)
 {
     return(BuildSqlScript("DELETE [", _migrationsTableName, "] WHERE Id = ", migration.Id));
 }
Exemplo n.º 10
0
 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)));
 }
Exemplo n.º 11
0
 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));
 }
Exemplo n.º 12
0
 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, ""));
 }