public void TestDatabaseSimple()
        {
            var tables = new TestDatabaseSimple().GetTables();

            Assert.AreEqual(1, tables.Count);
            Assert.AreEqual("Company", tables[0].SchemaAndTableName.TableName);
        }
        public void TestDatabaseSimple()
        {
            var tables = new TestDatabaseSimple().GetTables();

            var cfks = tables[0].Properties.OfType <CircularFK>().Count();

            Assert.AreEqual(0, cfks);
        }
Exemple #3
0
        protected static DatabaseDefinitions Index_Add_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddWithNewIndex = new TestDatabaseIndex();

            ddWithNewIndex.SetVersions(version.GetTypeMapper());

            return(new DatabaseDefinitions(ddOriginal, ddWithNewIndex, "TestDatabaseSimple", "TestDatabaseIndex_Index_Add"));
        }
Exemple #4
0
        protected static DatabaseDefinitions Table_Remove_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());
            AddTable(ddOriginal);

            var ddWithoutNewTable = new TestDatabaseSimple();

            ddWithoutNewTable.SetVersions(version.GetTypeMapper());

            return(new DatabaseDefinitions(ddOriginal, ddWithoutNewTable, "TestDatabaseSimple", "TestDatabaseSimple_Table_Remove"));
        }
Exemple #5
0
        protected static DatabaseDefinitions Column_Change_Nullable_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddNullableChanged = new TestDatabaseSimple();

            ddNullableChanged.SetVersions(version.GetTypeMapper());
            ddNullableChanged.GetTable("Company")["Name"].Type.IsNullable = !ddOriginal.GetTable("Company")["Name"].Type.IsNullable;

            return(new DatabaseDefinitions(ddOriginal, ddNullableChanged, "TestDatabaseSimple", "TestDatabaseSimple_Column_Change_Nullable"));
        }
Exemple #6
0
        protected static DatabaseDefinitions Column_Remove_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddColumnRemoved = new TestDatabaseSimple();

            ddColumnRemoved.SetVersions(version.GetTypeMapper());

            ddColumnRemoved.GetTable("Company").Columns.Remove("Name");

            return(new DatabaseDefinitions(ddOriginal, ddColumnRemoved, "TestDatabaseSimple", "TestDatabaseSimple_Column_Remove"));
        }
Exemple #7
0
        protected static DatabaseDefinitions Column_Add_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddWithNewColumn = new TestDatabaseSimple();

            ddWithNewColumn.SetVersions(version.GetTypeMapper());

            ddWithNewColumn.GetTable("Company").AddVarChar("Name2", 100);

            return(new DatabaseDefinitions(ddOriginal, ddWithNewColumn, "TestDatabaseSimple", "TestDatabaseSimple_Column_Add"));
        }
Exemple #8
0
        private static void AddTable(TestDatabaseSimple dd)
        {
            var newTable = new SqlTable
            {
                SchemaAndTableName = "NewTableToMigrate"
            };

            newTable.AddInt32("Id", false).SetPK().SetIdentity();

            new PrimaryKeyNamingDefaultStrategy().SetPrimaryKeyName(newTable.Properties.OfType <PrimaryKey>().First());

            newTable.AddNVarChar("Name", 100);

            dd.AddTable(newTable);
        }
Exemple #9
0
        protected static DatabaseDefinitions Identity_Change_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddIdentityChanged = new TestDatabaseSimple();

            ddIdentityChanged.SetVersions(version.GetTypeMapper());
            var identity = ddIdentityChanged.Company.Columns["Id"].Properties.OfType <Identity>().First();

            identity.Increment = 2;

            return(new DatabaseDefinitions(ddOriginal, ddIdentityChanged, "TestDatabaseSimple", "TestDatabaseSimple_Identity_Change"));
        }
Exemple #10
0
        protected static DatabaseDefinitions Column_Change2_Length_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());
            ddOriginal.GetTable("Company").AddNVarChar("Name2", 100);

            var ddColumnLengthsChanged = new TestDatabaseSimple();

            ddColumnLengthsChanged.SetVersions(version.GetTypeMapper());
            ddColumnLengthsChanged.GetTable("Company").AddNVarChar("Name2", 100);
            ddColumnLengthsChanged.GetTable("Company")["Name"].Type.Length  += 1;
            ddColumnLengthsChanged.GetTable("Company")["Name2"].Type.Length += 1;

            return(new DatabaseDefinitions(ddOriginal, ddColumnLengthsChanged, "TestDatabaseSimple", "TestDatabaseSimple_Column_Change2_Length"));
        }
Exemple #11
0
        protected static DatabaseDefinitions Column_Change_DbType_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddDbTypeChanged = new TestDatabaseSimple();

            ddDbTypeChanged.SetVersions(version.GetTypeMapper());

            if (version == MsSqlVersion.MsSql2016)
            {
                ddDbTypeChanged.GetTable("Company")["Name"].Type.SqlTypeInfo = MsSqlType2016.NChar;
            }
            else if (version == OracleVersion.Oracle12c)
            {
                ddDbTypeChanged.GetTable("Company")["Name"].Type.SqlTypeInfo = OracleType12c.NChar;
            }

            return(new DatabaseDefinitions(ddOriginal, ddDbTypeChanged, "TestDatabaseSimple", "TestDatabaseSimple_Column_Change_DbType"));
        }
Exemple #12
0
        protected static DatabaseDefinitions Pk_Add_Dds(SqlEngineVersion version)
        {
            var ddOriginal = new TestDatabaseSimple();

            ddOriginal.GetTable("Company").Columns["Id"].Properties.Remove(
                ddOriginal.GetTable("Company").Columns["Id"].Properties.OfType <Identity>().First()
                );
            ddOriginal.GetTable("Company").Properties.Remove(
                ddOriginal.GetTable("Company").Properties.OfType <PrimaryKey>().First()
                );
            ddOriginal.SetVersions(version.GetTypeMapper());

            var ddWithPk = new TestDatabaseSimple();

            ddWithPk.SetVersions(version.GetTypeMapper());
            ddWithPk.GetTable("Company").Columns["Id"].Properties.Remove(
                ddWithPk.GetTable("Company").Columns["Id"].Properties.OfType <Identity>().First()
                );

            return(new DatabaseDefinitions(ddOriginal, ddWithPk, "TestDatabaseSimple", "TestDatabaseSimple_Pk_Add"));
        }