Esempio n. 1
0
        public void Should_copy_writeable_property_from_meta()
        {
            // given
            A.CallTo(() => _metaProvider.GetMeta(PropertyInfo))
            .Returns(new SupportedPropertyMeta {
                Writeable = true
            });

            // when
            var property = _factory.Create(PropertyInfo, ClassIds);

            // then
            property.Writeable.Should().BeTrue();
        }
        /// <summary>
        /// Creates a hydra <see cref="SupportedProperty" /> from a type's property
        /// using sensible defaults.
        /// </summary>
        public virtual SupportedProperty Create(PropertyInfo prop, IReadOnlyDictionary <Type, Uri> classIds)
        {
            IriRef?mappedType = _rangeRetrieval.GetRange(prop, classIds);
            var    meta       = _metaProvider.GetMeta(prop);
            string propertyId = _propertyPredicateIdPolicy.GetPropertyId(prop, classIds[prop.ReflectedType]);

            var property = new SupportedProperty
            {
                Title       = meta.Title,
                Description = meta.Description,
                Writeable   = meta.Writeable,
                Readable    = meta.Readable,
                Property    =
                {
                    Id    = propertyId,
                    Range = mappedType ?? (IriRef)Hydra.Resource
                }
            };

            return(property);
        }