public void FindPropertyAccessorData_WithShadowedProperty()
        {
            var shadowingResult   = _derivedClassWithMixedPropertiesCache.FindPropertyAccessorData(typeof(DerivedClassWithDifferentProperties), "String");
            var shadowingExpected =
                _derivedClassWithMixedPropertiesCache.GetMandatoryPropertyAccessorData(typeof(DerivedClassWithDifferentProperties), "String");

            Assert.That(shadowingResult, Is.EqualTo(shadowingExpected));

            var shadowedResult   = _derivedClassWithMixedPropertiesCache.FindPropertyAccessorData(typeof(ClassWithDifferentProperties), "String");
            var shadowedExpected = _derivedClassWithMixedPropertiesCache.GetMandatoryPropertyAccessorData(typeof(ClassWithDifferentProperties), "String");

            Assert.That(shadowedResult, Is.EqualTo(shadowedExpected));
        }
        public void FindPropertyAccessorData_FromDerivedType()
        {
            Assert.That(_distributorCache.GetPropertyAccessorData(typeof(Distributor), "ContactPerson"), Is.Null);

            var result = _distributorCache.FindPropertyAccessorData(typeof(Distributor), "ContactPerson");

            var expected = _distributorCache.GetMandatoryPropertyAccessorData(typeof(Partner), "ContactPerson");

            Assert.That(result, Is.EqualTo(expected));
        }
        public void GetMandatoryPropertyAccessorData_FullPropertyName()
        {
            var data = _orderCache.GetMandatoryPropertyAccessorData(typeof(Order).FullName + ".OrderNumber");

            Assert.That(data, Is.Not.Null);
            Assert.That(data, Is.EqualTo(_orderCache.GetPropertyAccessorData(typeof(Order).FullName + ".OrderNumber")));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Selects the property of the domain object with the given name.
        /// </summary>
        /// <param name="propertyName">The name of the property to be accessed.</param>
        /// <param name="transaction">The transaction to use for accessing the property.</param>
        /// <returns>A <see cref="PropertyAccessor"/> instance encapsulating the requested property.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyName"/> parameter is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">
        /// The <paramref name="propertyName"/> parameter does not denote a valid mapping property of the domain object.
        /// </exception>
        public                         PropertyAccessor this[[NotNull] string propertyName, [NotNull] ClientTransaction transaction]
        {
            get
            {
                // PropertyAccessorDataCache checks the argument
                ArgumentUtility.DebugCheckNotNullOrEmpty("propertyName", propertyName);
                // GetPropertyAccessor checks the argument
                ArgumentUtility.DebugCheckNotNull("transaction", transaction);

                var data = PropertyAccessorDataCache.GetMandatoryPropertyAccessorData(propertyName);
                return(GetPropertyAccessor(transaction, data));
            }
        }
        public void FindPropertyAccessorData_FromGenericType()
        {
            Assert.That(
                _closedGenericClassCache.GetPropertyAccessorData(typeof(ClosedGenericClassWithManySideRelationProperties), "BaseUnidirectional"),
                Is.Null);

            var result = _closedGenericClassCache.FindPropertyAccessorData(typeof(ClosedGenericClassWithManySideRelationProperties), "BaseUnidirectional");

            var expected = _closedGenericClassCache.GetMandatoryPropertyAccessorData(
                typeof(GenericClassWithManySideRelationPropertiesNotInMapping <>),
                "BaseUnidirectional");

            Assert.That(result, Is.EqualTo(expected));
        }