Exemplo n.º 1
0
        public void GetMetadata_WithReadOnlyAttributeScalar()
        {
            IPropertyInformation propertyInfo      = GetPropertyInfo(typeof(ClassWithReferenceType <SimpleReferenceType>), "ReadOnlyAttributeScalar");
            PropertyReflector    propertyReflector = PropertyReflector.Create(propertyInfo, _businessObjectProvider);

            Assert.That(GetUnderlyingType(propertyReflector), Is.SameAs(typeof(SimpleReferenceType)));

            IBusinessObjectProperty businessObjectProperty = propertyReflector.GetMetadata();

            Assert.That(businessObjectProperty, Is.InstanceOf(typeof(PropertyBase)));
            Assert.That(((PropertyBase)businessObjectProperty).PropertyInfo, Is.SameAs(propertyInfo));
            Assert.That(businessObjectProperty.Identifier, Is.EqualTo("ReadOnlyAttributeScalar"));
            Assert.That(businessObjectProperty.PropertyType, Is.SameAs(typeof(SimpleReferenceType)));
            Assert.That(businessObjectProperty.IsList, Is.False);
            Assert.That(businessObjectProperty.IsRequired, Is.False);
            Assert.That(businessObjectProperty.IsReadOnly(null), Is.True);
        }
Exemplo n.º 2
0
        public void GetMetadata_WithUndefinedEnum()
        {
            IPropertyInformation IPropertyInformation = GetPropertyInfo(typeof(ClassWithUndefinedEnumValue), "Scalar");
            PropertyReflector    propertyReflector    = PropertyReflector.Create(IPropertyInformation, _businessObjectProvider);

            Assert.That(GetUnderlyingType(propertyReflector), Is.SameAs(typeof(EnumWithUndefinedValue)));

            IBusinessObjectProperty businessObjectProperty = propertyReflector.GetMetadata();

            Assert.That(businessObjectProperty, Is.InstanceOf(typeof(EnumerationProperty)));
            Assert.That(((PropertyBase)businessObjectProperty).PropertyInfo, Is.SameAs(IPropertyInformation));
            Assert.That(businessObjectProperty.Identifier, Is.EqualTo("Scalar"));
            Assert.That(businessObjectProperty.PropertyType, Is.SameAs(typeof(EnumWithUndefinedValue)));
            Assert.That(businessObjectProperty.IsList, Is.False);
            Assert.That(businessObjectProperty.IsRequired, Is.False);
            Assert.That(businessObjectProperty.IsReadOnly(null), Is.False);
        }
Exemplo n.º 3
0
        public void GetMetadata_WithListOfT()
        {
            IPropertyInformation IPropertyInformation = GetPropertyInfo(typeof(ClassWithListProperties), "ListOfT");
            PropertyReflector    propertyReflector    = PropertyReflector.Create(IPropertyInformation, _businessObjectProvider);

            Assert.That(GetUnderlyingType(propertyReflector), Is.SameAs(typeof(SimpleReferenceType)));

            IBusinessObjectProperty businessObjectProperty = propertyReflector.GetMetadata();

            Assert.That(businessObjectProperty, Is.InstanceOf(typeof(NotSupportedProperty)));
            Assert.That(((PropertyBase)businessObjectProperty).PropertyInfo, Is.SameAs(IPropertyInformation));
            Assert.That(businessObjectProperty.Identifier, Is.EqualTo("ListOfT"));
            Assert.That(businessObjectProperty.PropertyType, Is.SameAs(typeof(List <SimpleReferenceType>)));
            Assert.That(businessObjectProperty.IsList, Is.True);
            Assert.That(businessObjectProperty.ListInfo, Is.Not.Null);
            Assert.That(businessObjectProperty.ListInfo.ItemType, Is.SameAs(typeof(SimpleReferenceType)));
            Assert.That(businessObjectProperty.IsRequired, Is.False);
            Assert.That(businessObjectProperty.IsReadOnly(null), Is.False);
        }
Exemplo n.º 4
0
        public void GetMetadata_WithNullableArray()
        {
            IPropertyInformation IPropertyInformation = GetPropertyInfo(typeof(ClassWithValueType <SimpleValueType>), "NullableArray");
            PropertyReflector    propertyReflector    = PropertyReflector.Create(IPropertyInformation, _businessObjectProvider);

            Assert.That(GetUnderlyingType(propertyReflector), Is.SameAs(typeof(SimpleValueType)));

            IBusinessObjectProperty businessObjectProperty = propertyReflector.GetMetadata();

            Assert.That(businessObjectProperty, Is.InstanceOf(typeof(PropertyBase)));
            Assert.That(((PropertyBase)businessObjectProperty).PropertyInfo, Is.SameAs(IPropertyInformation));
            Assert.That(businessObjectProperty.Identifier, Is.EqualTo("NullableArray"));
            Assert.That(businessObjectProperty.PropertyType, Is.SameAs(typeof(SimpleValueType?[])));
            Assert.That(businessObjectProperty.IsList, Is.True);
            Assert.That(businessObjectProperty.ListInfo, Is.Not.Null);
            Assert.That(businessObjectProperty.ListInfo.ItemType, Is.SameAs(typeof(SimpleValueType?)));
            Assert.That(businessObjectProperty.IsRequired, Is.False);
            Assert.That(businessObjectProperty.IsReadOnly(null), Is.False);
        }
Exemplo n.º 5
0
        public void GetMetadata_WithReadOnlyMixedPropertyHavingSetterOnMixin()
        {
            IPropertyInformation propertyInfo = GetPropertyInfo(
                MixinTypeUtility.GetConcreteMixedType(typeof(ClassWithMixedProperty)),
                typeof(IMixinAddingProperty),
                "MixedReadOnlyPropertyHavingSetterOnMixin");

            Assertion.IsTrue(propertyInfo is MixinIntroducedPropertyInformation);

            PropertyReflector propertyReflector = PropertyReflector.Create(propertyInfo, _businessObjectProvider);

            Assert.That(GetUnderlyingType(propertyReflector), Is.SameAs(typeof(string)));

            IBusinessObjectProperty businessObjectProperty = propertyReflector.GetMetadata();

            Assert.That(businessObjectProperty, Is.InstanceOf(typeof(PropertyBase)));
            Assert.That(((PropertyBase)businessObjectProperty).PropertyInfo, Is.SameAs(propertyInfo));
            Assert.That(businessObjectProperty.Identifier, Is.EqualTo("MixedReadOnlyPropertyHavingSetterOnMixin"));
            Assert.That(businessObjectProperty.PropertyType, Is.SameAs(typeof(string)));
            Assert.That(businessObjectProperty.IsList, Is.False);
            Assert.That(businessObjectProperty.IsRequired, Is.False);
            Assert.That(businessObjectProperty.IsReadOnly(null), Is.True);
        }