예제 #1
0
        public void ExecuteSetCommandWithObjectProperty()
        {
            Machine machine = new Machine();
            TextWriter outwriter = new StringWriter();
            machine.Environment.SetValue("machine", machine);
            machine.Environment.SetValue("out", outwriter);

            DotExpression dotexpr = new DotExpression(new VariableExpression("machine"), "Out");
            SetCommand command = new SetCommand(dotexpr, new VariableExpression("out"));

            command.Execute(machine.Environment);

            Assert.AreEqual(machine.Out, outwriter);
        }
예제 #2
0
        public void ExecuteSetCommandWithVariable()
        {
            BindingEnvironment environment = new BindingEnvironment();
            SetCommand command = new SetCommand(new VariableExpression("foo"), new ConstantExpression("bar"));

            command.Execute(environment);

            Assert.AreEqual("bar", environment.GetValue("foo"));
        }
예제 #3
0
        public void ExecuteSetCommandWithDotExpression()
        {
            BindingEnvironment environment = new BindingEnvironment();
            DotExpression dotexpr = new DotExpression(new VariableExpression("foo"), "FirstName");
            SetCommand command = new SetCommand(dotexpr, new ConstantExpression("bar"));

            command.Execute(environment);

            object obj = environment.GetValue("foo");

            Assert.IsNotNull(obj);
            Assert.IsInstanceOfType(obj, typeof(DynamicObject));

            DynamicObject dynobj = (DynamicObject)obj;

            Assert.AreEqual("bar", dynobj.GetValue("FirstName"));
        }