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 + "',"); } } }
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 + "',"); } } }
private static void TryInvalidIsProperty(BeanEventType type, String property) { Assert.AreEqual(null, type.GetPropertyType(property)); Assert.AreEqual(false, type.IsProperty(property)); }