public void SqlIfCloneTest()
        {
            SqlSelect ifTrue = SqlDml.Select();

            ifTrue.Columns.Add(1, "id");
            SqlSelect ifFalse = SqlDml.Select();

            ifFalse.Columns.Add(2, "id");

            SqlIf i      = SqlDml.If(SqlDml.SubQuery(ifTrue) > 0, ifTrue);
            SqlIf iClone = (SqlIf)i.Clone();

            Assert.AreNotEqual(i, iClone);
            Assert.AreEqual(i.NodeType, iClone.NodeType);
            Assert.AreNotEqual(i.Condition, iClone.Condition);
            Assert.AreEqual(i.Condition.NodeType, iClone.Condition.NodeType);
            Assert.AreNotEqual(i.True, iClone.True);
            Assert.AreNotEqual(i.True.NodeType, iClone.NodeType);
            Assert.AreEqual(iClone.False, null);

            Console.WriteLine();

            i.False = ifFalse;
            iClone  = (SqlIf)i.Clone();

            Assert.AreNotEqual(i, iClone);
            Assert.AreEqual(i.NodeType, iClone.NodeType);
            Assert.AreNotEqual(i.Condition, iClone.Condition);
            Assert.AreEqual(i.Condition.NodeType, iClone.Condition.NodeType);
            Assert.AreNotEqual(i.True, iClone.True);
            Assert.AreNotEqual(i.True.NodeType, iClone.NodeType);
            Assert.AreNotEqual(i.False, iClone.False);
            Assert.AreEqual(i.False.NodeType, iClone.False.NodeType);
        }
        public void SqlWhileCloneTest()
        {
            SqlVariable i = SqlDml.Variable("i", SqlType.Int32);
            SqlWhile    w = SqlDml.While(i <= 1000);
            SqlBatch    b = SqlDml.Batch();

            b.Add(SqlDml.Assign(i, i + 1));
            SqlTableRef t = SqlDml.TableRef(table1);
            SqlSelect   s = SqlDml.Select(t);

            s.Columns.Add(t["Name"]);
            s.Where = t[0] == i;
            SqlIf f = SqlDml.If(SqlDml.SubQuery(s) == "Unkown", SqlDml.Break, SqlDml.Continue);

            b.Add(f);
            w.Statement = b;

            SqlWhile wClone = (SqlWhile)w.Clone();

            Assert.AreNotEqual(w, wClone);
            Assert.AreEqual(w.NodeType, wClone.NodeType);
            Assert.AreNotEqual(w.Condition, wClone.Condition);
            Assert.AreEqual(w.Condition.NodeType, wClone.Condition.NodeType);
            Assert.AreNotEqual(w.Statement, wClone.Statement);
            Assert.AreEqual(w.Statement.NodeType, wClone.Statement.NodeType);
        }
Example #3
0
 public void Visit(SqlIf node)
 {
     if (node.True != null)
     {
         Visit(node.True);
     }
     if (node.False != null)
     {
         Visit(node.False);
     }
     if (!node.Condition.IsNullReference())
     {
         Visit(node.Condition);
     }
 }
 public virtual void Visit(SqlIf node)
 {
     VisitInternal(node.Condition);
     VisitInternal(node.False);
     VisitInternal(node.True);
 }