Exemplo n.º 1
0
        public void VerifyTestMigrationSchema()
        {
            //run TestMigration migration, read, then remove...
            var runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out))
            {
                Namespace = typeof(TestMigration).Namespace
            };

            var runner = new MigrationRunner(typeof(TestMigration).Assembly, runnerContext, Processor);

            runner.Up(new TestMigration());

            //read schema here
            IList <TableDefinition> defs = SchemaDumper.ReadDbSchema();

            var    testWriter      = new SchemaTestWriter();
            var    output          = GetOutput(testWriter, defs);
            string expectedMessage = testWriter.GetMessage(4, 10, 4, 1);

            runner.Down(new TestMigration());
            runner.VersionLoader.RemoveVersionTable();

            //test
            output.ShouldBe(expectedMessage);
        }
Exemplo n.º 2
0
        public void TestSchemaTestWriter()
        {
            var tableDef = new TableDefinition
            {
                SchemaName = "dbo",
                Name       = "tableName",
                Columns    = new List <ColumnDefinition> {
                    new ColumnDefinition()
                },
                Indexes = new List <IndexDefinition> {
                    new IndexDefinition()
                },
                ForeignKeys = new List <ForeignKeyDefinition> {
                    new ForeignKeyDefinition()
                }
            };

            var defs = new List <TableDefinition> {
                tableDef
            };

            var    testWriter      = new SchemaTestWriter();
            var    output          = GetOutput(testWriter, defs);
            string expectedMessage = testWriter.GetMessage(1, 1, 1, 1);

            output.ShouldBe(expectedMessage);
        }
Exemplo n.º 3
0
        public void CanReadBasicSchemaInfo()
        {
            // this is the fun part.. this test should fail until the schema reading code works
            // also assume the target database contains schema described in TestMigration
            using (var table = new SqlServerTestTable(Processor, null, "id int")) {
                IList<TableDefinition> defs = SchemaDumper.ReadDbSchema();

                SchemaTestWriter testWriter = new SchemaTestWriter();
                var output = GetOutput(testWriter, defs);
                string expectedMessage = testWriter.GetMessage(1, 1, 0, 0);

                output.ShouldBe(expectedMessage);
            }
        }
Exemplo n.º 4
0
        public void CanReadBasicSchemaInfo()
        {
            // this is the fun part.. this test should fail until the schema reading code works
            // also assume the target database contains schema described in TestMigration
            using (var table = new SqlServerTestTable(Processor, null, "id int")) {
                IList <TableDefinition> defs = SchemaDumper.ReadDbSchema();

                SchemaTestWriter testWriter = new SchemaTestWriter();
                var    output          = GetOutput(testWriter, defs);
                string expectedMessage = testWriter.GetMessage(1, 1, 0, 0);

                output.ShouldBe(expectedMessage);
            }
        }
        public void TestSchemaTestWriter()
        {
            var tableDef = new TableDefinition
            {
                SchemaName = "dbo",
                Name = "tableName",
                Columns = new List<ColumnDefinition> { new ColumnDefinition() },
                Indexes = new List<IndexDefinition> { new IndexDefinition() },
                ForeignKeys = new List<ForeignKeyDefinition> { new ForeignKeyDefinition() }
            };

            var defs = new List<TableDefinition> {tableDef};

            var testWriter = new SchemaTestWriter();
            var output = GetOutput(testWriter, defs);
            string expectedMessage = testWriter.GetMessage(1, 1, 1, 1);

            output.ShouldBe(expectedMessage);
        }
Exemplo n.º 6
0
        public void CanReadBasicSchemaInfo()
        {
            // this is the fun part.. this test should fail until the schema reading code works
            // also assume the target database contains schema described in TestMigration
            using (new SqliteTestTable(Processor, null, "id int"))
            {
                try
                {
                    var defs = SchemaDumper.ReadDbSchema();

                    var testWriter      = new SchemaTestWriter();
                    var output          = GetOutput(testWriter, defs);
                    var expectedMessage = testWriter.GetMessage(1, 1, 0, 0);

                    output.ShouldBe(expectedMessage);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("CanReadBasicSchemaInfo exception :" + ex.StackTrace);
                    throw;
                }
            }
        }
Exemplo n.º 7
0
        public void VerifyTestMigrationSchema()
        {
            //run TestMigration migration, read, then remove...
            var runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out))
            {
                Namespace = typeof(TestMigration).Namespace
            };

            var runner = new MigrationRunner(typeof(TestMigration).Assembly, runnerContext, Processor);
            runner.Up(new TestMigration());

            //read schema here
            IList<TableDefinition> defs = SchemaDumper.ReadDbSchema();

            SchemaTestWriter testWriter = new SchemaTestWriter();
            var output = GetOutput(testWriter, defs);
            string expectedMessage = testWriter.GetMessage(4, 10, 4, 1);

            runner.Down(new TestMigration());

            //test
            output.ShouldBe(expectedMessage);
        }
        public void VerifyTestMigrationSchema()
        {
            //run TestMigration migration, read, then remove...
            var runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out))
            {
                Namespace =
                    typeof(TestMigration).Namespace
            };

            var runner = new MigrationRunner(typeof(TestMigration).Assembly, runnerContext, Processor);
            runner.Up(new TestMigration());

            //read schema here
            var defs = SchemaDumper.ReadDbSchema();

            var testWriter = new SchemaTestWriter();
            var output = GetOutput(testWriter, defs);
            // extra table testversion with 1 index
            var expectedMessage = testWriter.GetMessage(4, 10, 2, 0);

            runner.Down(new TestMigration());
            runner.VersionLoader.RemoveVersionTable();

            //test
            output.ShouldBe(expectedMessage);
        }
        public void CanReadBasicSchemaInfo()
        {
            // this is the fun part.. this test should fail until the schema reading code works
            // also assume the target database contains schema described in TestMigration
            using (new SqliteTestTable(Processor, null, "id int"))
            {
                try
                {
                    var defs = SchemaDumper.ReadDbSchema();

                    var testWriter = new SchemaTestWriter();
                    var output = GetOutput(testWriter, defs);
                    var expectedMessage = testWriter.GetMessage(1, 1, 0, 0);

                    output.ShouldBe(expectedMessage);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("CanReadBasicSchemaInfo exception :" + ex.StackTrace);
                    throw;
                }
            }
        }