示例#1
0
        public void RetrievalOfValueForInstanceOfDerivedTypeThroughNewAliasedFieldReturnsValueFromNewField()
        {
            FieldInfo            fieldInfo    = typeof(DerivedTestDomainObject).GetField("Field3");
            ValueAccess          valueAccess  = new FieldValueAccess(fieldInfo);
            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);
        }
示例#2
0
        public void RetrievalOfValueForNullReferenceReturnsFailure()
        {
            FieldInfo   fieldInfo   = typeof(BaseTestDomainObject).GetField("Field1");
            ValueAccess valueAccess = new FieldValueAccess(fieldInfo);

            object value;
            string valueAccessRetrievalFailure;
            bool   status = valueAccess.GetValue(null, out value, out valueAccessRetrievalFailure);

            Assert.IsFalse(status);
            Assert.IsNull(value);
            Assert.IsTrue(TemplateStringTester.IsMatch(Resources.ErrorValueAccessNull, valueAccessRetrievalFailure));
        }
示例#3
0
        public void CanGetValueFromFieldForInstanceOfDerivedClass()
        {
            FieldInfo            fieldInfo    = typeof(BaseTestDomainObject).GetField("Field1");
            ValueAccess          valueAccess  = new FieldValueAccess(fieldInfo);
            BaseTestDomainObject domainObject = new DerivedTestDomainObject();

            object value;
            string valueAccessRetrievalFailure;
            bool   status = valueAccess.GetValue(domainObject, out value, out valueAccessRetrievalFailure);

            Assert.IsTrue(status);
            Assert.AreEqual(BaseTestDomainObject.Base1Value, value);
        }