public void Can_get_properties() { var operation = new SqlResourceOperation(typeof(SqlResourceOperationTests).Assembly, "resourceName"); Assert.True(operation.ResourceName == "resourceName"); Assert.True(operation.Assembly == typeof(SqlResourceOperationTests).Assembly); }
public void Generate_SqlResourceOperation_produce_sql_file_statements() { var operation = new SqlResourceOperation(typeof(ExtendedSqlServerMigrationSqlGeneratorTests).Assembly, "UnitTests.fixtures.SqlResourceOperation.sql"); var sqlGenerator = new ExtendedSqlServerMigrationSqlGenerator(); var sql = sqlGenerator.Generate(new MigrationOperation[] { operation }, "2008").Join(ss => ss.Sql, Environment.NewLine); Assert.Contains("--drop database", sql); }
/// <summary> /// Generate sql from the embeded resource. /// </summary> /// <param name="sqlResourceOperation">The operation to produce sql for.</param> public virtual void Generate(SqlResourceOperation sqlResourceOperation) { using (var writer = Writer()) { var resourceStream = sqlResourceOperation.Assembly .GetManifestResourceStream(sqlResourceOperation.ResourceName); if (resourceStream != null) { using (var reader = new StreamReader(resourceStream)) { writer.Write(reader.ReadToEnd()); this.Statement(writer); } } else { throw Error.SqlResourceNotExist(sqlResourceOperation.ResourceName, sqlResourceOperation.Assembly.FullName); } } }