Ejemplo n.º 1
0
        public void ReadsColumnForeignKey()
        {
            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");
            Column          toColumn   = model.GetColumn("Customer", "CUSTOMER_ID");

            Assert.Same(toColumn, fromColumn.ForeignKey);
        }
Ejemplo n.º 2
0
        public void ReadsColumnLength()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID VARCHAR(10)
                        );";

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

            RelationalModel model  = reader.ReadRelationalModel();
            Column          column = model.GetColumn();

            Assert.NotNull(column.Length);
            Assert.Equal(10, column.Length.MaxSize);
        }
Ejemplo n.º 3
0
        public void ReadsColumnTable()
        {
            var sql = @"CREATE TABLE Customer (
							CUSTOMER_ID INT
                        );";

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

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

            Assert.NotNull(column.Table);
            Assert.Same(table, column.Table);
        }