public void BuildSymbolTable_TableNameAlreadyDefined()
        {
            var ast = new SqlSelectNode
            {
                Columns = new SqlListNode <ISqlNode>
                {
                    new SqlQualifiedIdentifierNode
                    {
                        Qualifier  = new SqlIdentifierNode("MyTable"),
                        Identifier = new SqlIdentifierNode("ColumnA")
                    }
                },
                FromClause = new SqlJoinNode
                {
                    Left = new SqlIdentifierNode {
                        Name = "MyTable"
                    },
                    Operator = new SqlOperatorNode("NATURAL JOIN"),
                    Right    = new SqlIdentifierNode {
                        Name = "MyTable"
                    }
                }
            };
            Action act = () => ast.BuildSymbolTables();

            act.Should().Throw <SymbolAlreadyDefinedException>().And.Symbol.Should().Be("MyTable");
        }
        public void BuildSymbolTable_TableNameNotDefined()
        {
            var ast = new SqlSelectNode
            {
                Columns = new SqlListNode <ISqlNode>
                {
                    new SqlQualifiedIdentifierNode
                    {
                        Qualifier  = new SqlIdentifierNode("MyTable2"),
                        Identifier = new SqlIdentifierNode("ColumnA")
                    }
                },
                FromClause = new SqlIdentifierNode {
                    Name = "MyTable1"
                }
            };
            Action act = () => ast.BuildSymbolTables();

            act.Should().Throw <SymbolNotDefinedException>().And.Symbol.Should().Be("MyTable2");
        }
        public void BuildSymbolTable_TableName()
        {
            var ast = new SqlSelectNode
            {
                Columns = new SqlListNode <ISqlNode>
                {
                    new SqlQualifiedIdentifierNode
                    {
                        Qualifier  = new SqlIdentifierNode("MyTable"),
                        Identifier = new SqlIdentifierNode("ColumnA")
                    }
                },
                FromClause = new SqlIdentifierNode {
                    Name = "MyTable"
                }
            };

            ast.BuildSymbolTables();
            ast.Symbols.GetInfoOrThrow("MyTable", null).OriginKind.Should().Be(SymbolOriginKind.Environmental);
            ast.Symbols.GetInfoOrThrow("ColumnA", null).OriginKind.Should().Be(SymbolOriginKind.Environmental);
        }