Ejemplo n.º 1
0
        public void ParseHostedExpression()
        {
            IExpression expression = ParseExpression("at host x+y");

            Assert.IsNotNull(expression);
            Assert.IsInstanceOfType(expression, typeof(HostedExpression));
            HostedExpression hexpr = (HostedExpression)expression;

            Assert.IsInstanceOfType(hexpr.HostExpression, typeof(VariableExpression));
        }
Ejemplo n.º 2
0
        public void EvaluateHostedExpression()
        {
            Host host  = new Host(new Machine());
            Host host2 = new Host(new Machine(false));

            host.Machine.Environment.SetValue("host", host2);
            host2.Machine.Environment.SetValue("foo", "bar");
            HostedExpression expression = new HostedExpression(new VariableExpression("foo"), new VariableExpression("host"));

            object result = expression.Evaluate(host.Machine.Environment);

            Assert.AreSame(Machine.Current, host.Machine);
            Assert.AreEqual("bar", result);
            Assert.IsNull(host.Machine.Environment.GetValue("foo"));
        }