Beispiel #1
0
        public void UtilsTest_Extendable_SetNull()
        {
            var ext = new ExtendableObject();

            ext.SetExtendedProperty("DynamicProperty", "Value1");

            Assert.AreEqual(1, ext.ExtendedPropertiesCount);

            ext.SetExtendedProperty("DynamicProperty", null);
            Assert.AreEqual(0, ext.ExtendedPropertiesCount, "设置为 null 后,需要清空数据。");
        }
Beispiel #2
0
        public void UtilsTest_Extendable_Reflection()
        {
            var ext = new ExtendableObject();

            ext.SetExtendedProperty("DynamicProperty", "Value1");
            ext.SetExtendedProperty("DynamicProperty2", "Value2");

            var dpList = ext.GetExtendedProperties();

            Assert.AreEqual(2, dpList.Count);
            Assert.IsTrue(dpList.ContainsKey("DynamicProperty"));
            Assert.IsTrue(dpList.ContainsKey("DynamicProperty2"));
            Assert.AreEqual("Value1", dpList["DynamicProperty"]);
            Assert.AreEqual("Value2", dpList["DynamicProperty2"]);
        }
Beispiel #3
0
        public void UtilsTest_Extendable()
        {
            var ext = new ExtendableObject();

            ext.SetExtendedProperty("DynamicProperty", "DDDD");

            Assert.AreEqual("DDDD", ext["DynamicProperty"]);
        }
Beispiel #4
0
        public void UtilsTest_Extendable_GetOrDefault()
        {
            var ext   = new ExtendableObject();
            var value = ext.GetPropertyOrDefault("DN", "HAHA");

            Assert.AreEqual("HAHA", value);
            ext.SetExtendedProperty("DN", "Value2");
            value = ext.GetPropertyOrDefault("DN", "HAHA");
            Assert.AreEqual("Value2", value);
        }