protected CommandBuilderTestBase()
        {
            CurrentSource = new Source("My Data");
            CurrentSource.Schemas.Add("SchemaA");
            CurrentSource.AddFunction("Function A", "dbo", "My Definition");
            CurrentSource.AddStoredProcedure("Stored Procedure A", "dbo", "My Definition");
            var Table = CurrentSource.AddTable("Table A", "dbo");

            Table.AddCheckConstraint("Constraint A", "My Definition");
            Table.AddColumn <int>("Column A", DbType.Int32);
            Table.AddTrigger("Trigger A", "My Definition", TriggerType.Insert);
            //Table.AddForeignKey("Column A", "Foreign Table", "Foreign Column");
            CurrentSource.AddView("View A", "dbo", "My Definition");
            var ForeignTable = CurrentSource.AddTable("Foreign Table", "dbo");

            ForeignTable.AddColumn <int>("Foreign Column", DbType.Int32);
            Table.SetupForeignKeys();

            DesiredSource = new Source("My Data");
            DesiredSource.Schemas.Add("SchemaA");
            DesiredSource.AddFunction("Function A", "dbo", "My Definition 2");
            DesiredSource.AddStoredProcedure("Stored Procedure A", "dbo", "My Definition 2");
            Table = DesiredSource.AddTable("Table A", "dbo");
            Table.AddCheckConstraint("Constraint A", "My Definition2");
            Table.AddColumn <int>("Column A", DbType.Int32);
            Table.AddColumn <string>("Column B", DbType.String);
            Table.AddTrigger("Trigger A", "My Definition 2", TriggerType.Update);
            Table.AddForeignKey("Column A", "Foreign Table", "Foreign Column");
            DesiredSource.AddView("View A", "dbo", "My Definition 2");
            ForeignTable = DesiredSource.AddTable("Foreign Table", "dbo");
            ForeignTable.AddColumn <int>("Foreign Column", DbType.Int32);
            Table.SetupForeignKeys();
        }
Exemple #2
0
        public void FillSource()
        {
            var TempViews        = new Views();
            var TempSource       = new Source("My Source");
            var TempTable        = TempSource.AddView("View A", "dbo", "");
            var ConstraintsToAdd = new List <dynamic>
            {
                new Dynamo(new
                {
                    View        = "View A",
                    Definition  = "My Definition",
                    Column      = "Column A",
                    COLUMN_TYPE = "Int",
                    MAX_LENGTH  = 4,
                    IS_NULLABLE = false
                })
            };

            TempViews.FillSource(ConstraintsToAdd, TempSource);
            var TempTable2 = (View)TempSource.Views[0];
            var Column     = TempTable2.Columns[0];

            Assert.Equal("Column A", Column.Name);
            Assert.Equal("My Definition", TempTable.Definition);
            Assert.Equal(DbType.Int32, Column.DataType);
        }
Exemple #3
0
        public void AddView()
        {
            var TempSource = new Source("MySource");
            var TempView   = TempSource.AddView("ViewName", "dbo", "ViewDefinition");

            Assert.Equal("ViewName", TempView.Name);
            Assert.Equal(TempSource, TempView.Source);
            Assert.Equal("ViewDefinition", TempView.Definition);
        }
Exemple #4
0
        public void Copy()
        {
            var TempSource = new Source("MySource");

            _ = TempSource.AddTable("TableName", "dbo");
            _ = TempSource.AddView("ViewName", "dbo", "ViewDefinition");
            _ = TempSource.AddStoredProcedure("ProcedureName", "dbo", "ProcedureDefinition");
            _ = TempSource.AddFunction("FunctionName", "dbo", "FunctionDefinition");
            var TempCopy = TempSource.Copy();

            Assert.Equal(TempSource, TempCopy);
        }