예제 #1
0
        private static void RunTest(PropTestDesc test, BeanEventType eventType, EventBean eventBean)
        {
            var 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 + "',");

            var getter = eventType.GetGetter(propertyName);

            if (getter == null)
            {
                Assert.IsFalse(test.HasGetter, "getGetter null on '" + propertyName + "',");
            }
            else
            {
                Assert.IsTrue(test.HasGetter, "getGetter not null on '" + propertyName + "',");
                if (ReferenceEquals(test.GetterReturnValue, typeof(NullReferenceException)))
                {
                    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 + "',");
                }
            }
        }
예제 #2
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 + "',");
                }
            }
        }