Example #1
0
        public void Should_create_PropertyAccessor_for_property()
        {
            // Arrange
            var property = new ClassWithPropertiesOnly()
                           .Property(o => o.StringPropertyWithGetSet);

            // Act
            IPropertyAccessor accessor = sut.Create(property);

            // Assert
            accessor.Should().NotBeNull();
        }
Example #2
0
        public void Returns_name_of_the_property()
        {
            // Arrange
            var property = new ClassWithPropertiesOnly()
                           .Property(o => o.StringPropertyWithGetSet);

            IPropertyAccessor sut = sutFactory.Create(property);

            // Act
            var actual = sut.Name;

            // Assert
            actual.Should().Be(property.Name);
        }
        /// <inheritdoc cref="IPropertyAccessorFactory.Create"/>
        public IPropertyAccessor Create(PropertyInfo property)
        {
            var key = objectCache.GetKey(property);

            var accessor = objectCache.GetOrAdd(key, () => decorated.Create(property));

            return(accessor as IPropertyAccessor);
        }
Example #4
0
        private IPropertyAccessor CreatePropertyAccessor(ILocation declaration, ILocation bodyStart, ILocation bodyEnd, BlockSyntax body)
        {
            var underlyingSyntaxNode = underlyingObjectFactory.Create(body);

            return(propertyAccessorFactory.Create(declaration, bodyStart, bodyEnd, underlyingSyntaxNode));
        }
 /// <inheritdoc cref="IPropertyProvider.GetProperties"/>
 public IEnumerable <IPropertyAccessor> GetProperties(object source)
 {
     return(typePropertyProvider
            .GetProperties(source)
            .Select(property => propertyAccessorFactory.Create(property)));
 }