Ejemplo n.º 1
0
        public void ReadsSingleColumn()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel      model   = reader.ReadRelationalModel();
            IEnumerable <Column> columns = model.GetTable().Columns;

            Assert.Single(columns);
        }
Ejemplo n.º 2
0
        public void ReadsTableName(string name, string expected)
        {
            var sql = $@"CREATE TABLE {name} (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model = reader.ReadRelationalModel();
            Table           table = model.GetTable();

            Assert.Equal(expected, table.Name);
        }
Ejemplo n.º 3
0
        public void ReadsNonNullTable()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model = reader.ReadRelationalModel();
            Table           table = model.GetTable();

            Assert.NotNull(table);
        }
Ejemplo n.º 4
0
        public void ReadsColumnForeignKeyTable()
        {
            var sql = @"CREATE TABLE Customer (
                            CUSTOMER_ID INT PRIMARY KEY
                        );
                        CREATE TABLE CustomerAddresses (
                            CUSTOMER_ADDRESS_ID INT PRIMARY KEY,
                            CUSTOMER_ID INT,
                            FOREIGN KEY(CUSTOMER_ID) REFERENCES Customer(CUSTOMER_ID)
                        );";

            ExecuteSqlCommand(sql);
            IRelationalModelReader reader = CreateRelationalModelReader();

            RelationalModel model      = reader.ReadRelationalModel();
            Column          fromColumn = model.GetColumn("CustomerAddresses", "CUSTOMER_ID");
            Table           toTable    = model.GetTable("Customer");

            Assert.Same(toTable, fromColumn.ForeignKey.Table);
        }
Ejemplo n.º 5
0
 public static Column GetColumn(this RelationalModel model, string tableName, string columnName)
 {
     return(model.GetTable(tableName).Columns.First(c => c.Name == columnName));
 }
Ejemplo n.º 6
0
 public static Column GetColumn(this RelationalModel model)
 {
     return(model.GetTable().Columns.First());
 }