public void ExecuteSetLocalVariable() { BindingEnvironment environment = new BindingEnvironment(); Assert.IsNull(environment.GetValue("foo")); SetLocalVariableCommand cmd = new SetLocalVariableCommand("foo", new ConstantExpression("bar")); cmd.Execute(environment); Assert.AreEqual("bar", environment.GetValue("foo")); }
public void ParseSetLocalVariableCommand() { ICommand command = ParseCommand("a = 1"); Assert.IsNotNull(command); Assert.IsInstanceOfType(command, typeof(SetLocalVariableCommand)); SetLocalVariableCommand setcmd = (SetLocalVariableCommand)command; Assert.AreEqual("a", setcmd.VariableName); Assert.IsNotNull(setcmd.Expression); Assert.IsInstanceOfType(setcmd.Expression, typeof(ConstantExpression)); Assert.AreEqual(1, setcmd.Expression.Evaluate(null)); }
protected internal override void VisitSetLocalVariableCommand(SetLocalVariableCommand setLocalVariableCommand) { this.WriteIndent(); this.writer.WriteLine("setvar {0} {1} {2}", setLocalVariableCommand.Left, this.ToString(setLocalVariableCommand.Operation), setLocalVariableCommand.Right); }