Esempio n. 1
0
        public void SetValue_OnAField_ShouldSetValue()
        {
            var typeInfo = GetTypeInfo(typeof(TypeInfoTestType));
            var obj = new TypeInfoTestType();

            Assert.AreEqual(0, obj.myField);
            bool valueSetted = typeInfo.SetValue("myField", obj, 80);
            Assert.IsTrue(valueSetted);
            Assert.AreEqual(80, obj.myField);
        }
Esempio n. 2
0
        public void SetValue_OnAProperty_ShouldSetValue()
        {
            var typeInfo = GetTypeInfo(typeof(TypeInfoTestType));
            var obj = new TypeInfoTestType();

            Assert.IsNull(obj.MyProperty);
            bool valueSetted = typeInfo.SetValue("myProperty", obj, "New value");
            Assert.IsTrue(valueSetted);
            Assert.AreEqual("New value", obj.MyProperty);
        }
Esempio n. 3
0
        public void SetValue_OnAnUnexistingMember_ShouldDoNothing()
        {
            var typeInfo = GetTypeInfo(typeof(TypeInfoTestType));
            var obj = new TypeInfoTestType();

            Assert.AreEqual(0, obj.myField);
            Assert.IsNull(obj.MyProperty);
            bool valueSetted = typeInfo.SetValue("unexisting", obj, "...");
            Assert.IsFalse(valueSetted);
            Assert.AreEqual(0, obj.myField);
            Assert.IsNull(obj.MyProperty);
        }