public void GetUndefinedAttributeAsNull()
        {
            DefinedClass klass = new DefinedClass("Spam");

            Assert.IsNull(klass.GetValue("foo"));
            Assert.IsFalse(klass.HasValue("foo"));
        }
        public void SetGetAttribute()
        {
            DefinedClass klass = new DefinedClass("Spam");

            klass.SetValue("one", 1);

            var result = klass.GetValue("one");

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
            Assert.IsTrue(klass.HasValue("one"));
        }
        public void GetValueFromSuperClass()
        {
            DefinedClass super = new DefinedClass("object");

            super.SetValue("foo", 1);
            DefinedClass klass = new DefinedClass("Spam", new IType[] { super });

            var result = klass.GetValue("foo");

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result);
            Assert.IsTrue(klass.HasValue("foo"));
        }
        public void RedefineValueFromClass()
        {
            DefinedClass  klass  = new DefinedClass("Spam");
            DynamicObject dynobj = new DynamicObject(klass);

            klass.SetValue("one", 1);
            dynobj.SetValue("one", 2);
            var result = dynobj.GetValue("one");

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result);
            Assert.IsTrue(dynobj.HasValue("one"));
            Assert.AreEqual(1, klass.GetValue("one"));
        }
        public void ReplaceMethodWithAttribute()
        {
            DefinedClass klass  = new DefinedClass("Spam");
            IFunction    method = new NativeMethod(this.DummyMethod);

            klass.SetMethod("foo", method);
            klass.SetValue("foo", 1);

            var result = klass.GetMethod("foo");

            Assert.IsNull(result);
            Assert.IsFalse(klass.HasMethod("foo"));
            Assert.AreEqual(1, klass.GetValue("foo"));
            Assert.IsTrue(klass.HasValue("foo"));
        }