Exemplo n.º 1
0
 public void GetStatementVariables00()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         // Null as argument will cause exception.
         CodeBlockUtils.GetStatementVariables(null, true);
     });
 }
Exemplo n.º 2
0
        public void GetStatementVariables01()
        {
            // Create a statement of "Value = 1234".
            var leftNode    = new IdentifierNode("Value");
            var rightNode   = new IntNode(1234);
            var binExprNode = new BinaryExpressionNode(
                leftNode, rightNode, Operator.assign);

            var statements = new List <Statement>()
            {
                Statement.CreateInstance(binExprNode)
            };

            var vars = CodeBlockUtils.GetStatementVariables(statements, true);

            Assert.IsNotNull(vars);
            Assert.AreEqual(1, vars.Count());

            var variables = vars.ElementAt(0);

            Assert.IsNotNull(variables);
            Assert.AreEqual(1, variables.Count());
            Assert.AreEqual("Value", variables.ElementAt(0));
        }