public void GetUndefinedAttributeAsNull() { DefinedClass klass = new DefinedClass("Spam"); DynamicObject dynobj = new DynamicObject(klass); var result = dynobj.GetValue("foo"); Assert.IsNull(result); Assert.IsFalse(dynobj.HasValue("foo")); }
public void GetValueFromClass() { DefinedClass klass = new DefinedClass("Spam"); DynamicObject dynobj = new DynamicObject(klass); klass.SetValue("one", 1); var result = dynobj.GetValue("one"); Assert.IsNotNull(result); Assert.AreEqual(1, result); Assert.IsTrue(dynobj.HasValue("one")); }
public void SetAttributeInDynamicObject() { BindingEnvironment environment = new BindingEnvironment(); DefinedClass klass = new DefinedClass("Spam"); DynamicObject dynobj = new DynamicObject(klass); environment.SetValue("foo", dynobj); SetAttributeCommand command = new SetAttributeCommand(new NameExpression("foo"), "one", new ConstantExpression(1)); command.Execute(environment); Assert.IsTrue(dynobj.HasValue("one")); Assert.AreEqual(1, dynobj.GetValue("one")); }