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); }
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")); }
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")); }