Esempio n. 1
0
        private static void RunTest(PropTestDesc test, BeanEventType eventType, EventBean eventBean)
        {
            String propertyName = test.PropertyName;

            Assert.AreEqual(test.IsProperty, eventType.IsProperty(propertyName), "isProperty mismatch on '" + propertyName + "',");
            Assert.AreEqual(test.Clazz, eventType.GetPropertyType(propertyName), "getPropertyType mismatch on '" + propertyName + "',");

            EventPropertyGetter getter = eventType.GetGetterSPI(propertyName);

            if (getter == null)
            {
                Assert.IsFalse(test.HasGetter, "getGetter null on '" + propertyName + "',");
            }
            else
            {
                Assert.IsTrue(test.HasGetter, "getGetter not null on '" + propertyName + "',");
#pragma warning disable CS0252 // Possible unintended reference comparison; left hand side needs cast
                if (test.GetterReturnValue == typeof(NullReferenceException))
                {
#pragma warning restore CS0252 // Possible unintended reference comparison; left hand side needs cast
                    try {
                        getter.Get(eventBean);
                        Assert.Fail("getGetter not throwing null pointer on '" + propertyName);
                    } catch (NullReferenceException) {
                        // expected
                    }
                }
                else
                {
                    var value = getter.Get(eventBean);
                    Assert.AreEqual(test.GetterReturnValue, value, "getter value mismatch on '" + propertyName + "',");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="type">the type of read</param>
        public BeanEventBeanReader(BeanEventType type)
        {
            var properties = type.PropertyNames;
            var getters    = new List <BeanEventPropertyGetter>();

            foreach (string property in properties)
            {
                var getter = (BeanEventPropertyGetter)type.GetGetterSPI(property);
                if (getter != null)
                {
                    getters.Add(getter);
                }
            }
            _getterArray = getters.ToArray();
        }