public void RetrievalOfValueForInstanceOfDerivedTypeThroughNewAliasedMethodReturnsValueFromNewMethod() { MethodInfo methodInfo = typeof(DerivedTestDomainObject).GetMethod("Method3"); ValueAccess valueAccess = new MethodValueAccess(methodInfo); BaseTestDomainObject domainObject = new DerivedTestDomainObject(); object value; string valueAccessRetrievalFailure; bool status = valueAccess.GetValue(domainObject, out value, out valueAccessRetrievalFailure); Assert.IsTrue(status); Assert.AreEqual(DerivedTestDomainObject.Derived3Value, value); }
public void RetrievalOfValueForInstanceOfNonRelatedTypeReturnsFailure() { MethodInfo methodInfo = typeof(BaseTestDomainObject).GetMethod("Method1"); ValueAccess valueAccess = new MethodValueAccess(methodInfo); object value; string valueAccessRetrievalFailure; bool status = valueAccess.GetValue("a string", out value, out valueAccessRetrievalFailure); Assert.IsFalse(status); Assert.IsNull(value); Assert.IsTrue(TemplateStringTester.IsMatch(Resources.ErrorValueAccessInvalidType, valueAccessRetrievalFailure)); }
public void CanGetValueFromOverridenMethodForInstanceOfDerivedClass() { MethodInfo methodInfo = typeof(BaseTestDomainObject).GetMethod("Method2"); ValueAccess valueAccess = new MethodValueAccess(methodInfo); BaseTestDomainObject domainObject = new DerivedTestDomainObject(); object value; string valueAccessRetrievalFailure; bool status = valueAccess.GetValue(domainObject, out value, out valueAccessRetrievalFailure); Assert.IsTrue(status); Assert.AreEqual(DerivedTestDomainObject.Derived2Value, value); }