public void SetValues() {
            PropertyCollection properties = new PropertyCollection();
            properties.Add("DoubleProperty", "9999.5");
            properties.Add("IntProperty", "123456");
            properties.Add("StringProperty", "AAAA");

            PropertyUtil.SetValues(testObject, properties);
            Assert.AreEqual(9999.5, testObject.DoubleProperty);
            Assert.AreEqual(123456, testObject.IntProperty);
            Assert.AreEqual("AAAA", testObject.StringProperty);
        }
        public void SetValues_ArgumentNull_1() {
            PropertyCollection properties = new PropertyCollection();
            Assert.Throws<ArgumentNullException>(() => PropertyUtil.SetValues(null, properties));

        }
Example #3
0
        public static void SetValues(object obj, PropertyCollection properties) {
            if (obj == null)
                throw new ArgumentNullException("obj");
            if (properties == null) {
                return;
            }

            foreach (string name in properties.GetAllKeys()) {
                TrySetValue(obj, name, properties[name]);
            }
        }