public Execute ( Context context ) : object | ||
context | Context | |
Результат | object |
public void DefineVariableWithInitialValue() { Context context = new Context(); DefineVariableCommand expr = new DefineVariableCommand(null, "a", new ConstantExpression(1)); Assert.AreEqual(1, expr.Execute(context)); Assert.IsTrue(context.HasVariable("a")); Assert.AreEqual(1, context.GetValue("a")); Assert.AreEqual("a", expr.Name); Assert.IsNull(expr.TypeExpression); }
public void DefineVariableWithTypeAndInitialValue() { Context context = new Context(); IExpression typeexpr = new VariableExpression("List"); DefineVariableCommand expr = new DefineVariableCommand(typeexpr, "a", new ConstantExpression(1)); Assert.AreEqual(1, expr.Execute(context)); Assert.IsTrue(context.HasVariable("a")); Assert.AreEqual(1, context.GetValue("a")); Assert.AreEqual("a", expr.Name); Assert.AreEqual(typeexpr, expr.TypeExpression); }