Inheritance: IProvider, IRecordedMigration
Ejemplo n.º 1
0
 public void VerifyNewObjectNamesAreRecorded()
 {
     var provider = new RecordingProvider();
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed : needed to force enumeration
     provider.CreateTable(new TableName("Table", null), new[] { new CreatedColumn("Column", new DataType(DbType.Boolean), false, true, string.Empty, false, null, false) }, "MyPK").ToList();
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
     CollectionAssert.AreEquivalent(new[] { "Table", "Column", "MyPK" }, provider.NewObjectNames.ToList());
 }
Ejemplo n.º 2
0
 public void VerifyMethodNamesAreRecorded()
 {
     var provider = new RecordingProvider();
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed : needed to force enumeration
     provider.RenameColumn(new TableName("Table", null), "OldColumn", "NewColumn").ToList();
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
     CollectionAssert.AreEquivalent(new[] { "RenameColumn" }, provider.Methods.ToList());
 }
 public void VerifyDateTypesAreRecorded()
 {
     var provider = new RecordingProvider();
     provider.CreateTable("Table", new[]
     {
         new CreatedColumn("Primary Key Column", new DataType(DbType.Int32, 0, 0), false, true, string.Empty, false, null),
         new CreatedColumn("Identity Column", new DataType(DbType.Int64, 0, 0), false, false, string.Empty, true, null),
         new CreatedColumn("Column", new DataType(DbType.String, 0, 0), false, false, string.Empty, false, null),
     }, "MyPK").ToList();
     CollectionAssert.AreEquivalent(new[]
     {
         new UsedDataType(new DataType(DbType.Int32, 0, 0), true, false),
         new UsedDataType(new DataType(DbType.Int64, 0, 0), false, true),
         new UsedDataType(new DataType(DbType.String, 0, 0), false, false),
     }, provider.DataTypes.ToList());
 }
Ejemplo n.º 4
0
 public void VerifyDateTypesAreRecorded()
 {
     var provider = new RecordingProvider();
     provider.CreateTable(new TableName("Table", null), new[]
     {
         new CreatedColumn("Primary Key Column", new DataType(DbType.Int32), false, true, string.Empty, false, null, false),
         new CreatedColumn("Identity Column", new DataType(DbType.Int64), false, false, string.Empty, true, null, false),
         new CreatedColumn("Column", new DataType(DbType.String, 10), false, false, string.Empty, false, null, false),
     // ReSharper disable ReturnValueOfPureMethodIsNotUsed : needed to force enumeration
     }, "MyPK").ToList();
     // ReSharper restore ReturnValueOfPureMethodIsNotUsed
     CollectionAssert.AreEquivalent(new[]
     {
         new UsedDataType(new DataType(DbType.Int32), true, false),
         new UsedDataType(new DataType(DbType.Int64), false, true),
         new UsedDataType(new DataType(DbType.String, 10), false, false),
     }, provider.DataTypes.ToList());
 }
Ejemplo n.º 5
0
        public static MigrationReport Create(Database database, string migrationName)
        {
            // execute changes in 'database' against a RecordingProvider
            var recordingProvider = new RecordingProvider();
            var translator = new CommandsToSqlTranslator(recordingProvider);
            string error = string.Empty;
            try
            {
                translator.TranslateToSql(database, null).ToList(); // .ToList() is important to effectively trigger the iteration
            }
            catch (InvalidCommandException x)
            {
                error = x.Message;
            }

            // create MigrationReport
            return new MigrationReport(migrationName, error, recordingProvider);
        }
Ejemplo n.º 6
0
        public static MigrationReport Create(Database database, string migrationName, IMigrationContext context)
        {
            // execute changes in 'database' against a RecordingProvider
            var recordingProvider = new RecordingProvider();
            var translator = new CommandsToSqlTranslator(recordingProvider);
            string error = string.Empty;
            try
            {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
                translator.TranslateToSql(database, context).ToList(); // .ToList() is important to effectively trigger the iteration
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
            }
            catch (InvalidCommandException x)
            {
                error = x.Message;
            }

            // create MigrationReport
            return new MigrationReport(migrationName, error, recordingProvider);
        }
 public void VerifyNewObjectNamesAreRecorded()
 {
     var provider = new RecordingProvider();
     provider.CreateTable("Table", new[] { new CreatedColumn("Column", new DataType(DbType.Boolean, 0, 0), false, true, string.Empty, false, null) }, "MyPK").ToList();
     CollectionAssert.AreEquivalent(new[] { "Table", "Column", "MyPK" }, provider.NewObjectNames.ToList());
 }
 public void VerifyMethodNamesAreRecorded()
 {
     var provider = new RecordingProvider();
     provider.RenameColumn("Table", "OldColumn", "NewColumn").ToList();
     CollectionAssert.AreEquivalent(new[] { "RenameColumn" }, provider.Methods.ToList());
 }