Inheritance: MemberAccessNode
Exemplo n.º 1
0
        public void ParseMethodAccess()
        {
            string s = "hello";
            Expression<Func<string>> f = () => s.Substring(1);
            var node = ExpressionParser.Parse(f.Body);

            var expected = new MethodCallNode
            {
                Container = new ConstantNode {Text = "s", Value = @"""hello"""},
                MemberName = "Substring",
                MemberValue = @"""ello""",
                Parameters = new List<Node>() {new ConstantNode {Text = "1"}}
            };

            Assert.AreEqual(expected, node);
        }
Exemplo n.º 2
0
        public void ParseMethodWithException()
        {
            Expression<Func<int>> f = () => ThrowException();
            var node = ExpressionParser.Parse(f.Body);

            var expected = new MethodCallNode
                                        {
                                            Container = new ConstantNode { Text = "PowerAssertTests.ParserTest"},
                                            MemberName = "ThrowException",
                                            MemberValue = @"DivideByZeroException: Attempted to divide by zero.",
                                        };

            Assert.AreEqual(expected, node);
        }