예제 #1
0
        public void Created_accessor_must_return_value_from_source_property()
        {
            // Arrange
            var source   = new ClassWithPropertiesOnly();
            var property = source.Property(o => o.StringPropertyWithGetSet);

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

            // Assert
            accessor.GetValue(source).Should().Be(source.StringPropertyWithGetSet);
        }
예제 #2
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();
        }
        public void When_property_type_is_buildIn_Then_returns_FALSE()
        {
            // Arrange
            var property = new ClassWithPropertiesOnly()
                           .Property(o => o.StringPropertyWithGetSet);

            // Act
            var actual = sut.IsReference(property);

            // Assert
            actual.Should().BeFalse();
        }
예제 #4
0
        public void Can_get_value_from_object_property()
        {
            // Arrange
            var source   = new ClassWithPropertiesOnly();
            var property = source.Property(o => o.StringPropertyWithGetSet);

            IPropertyAccessor sut = sutFactory.Create(property);

            // Act
            var actualValue = sut.GetValue(source);

            // Assert
            actualValue.Should().Be(source.StringPropertyWithGetSet);
        }
예제 #5
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);
        }
예제 #6
0
        public void Must_create_an_accessor_for_builtIn_types()
        {
            // Arrange
            var source   = new ClassWithPropertiesOnly();
            var property = source.Property(o => o.StringPropertyWithGetSet);

            referenceCheckerMock
            .IsReference(property)
            .Returns(false);

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

            // Assert
            accessor.IsReference.Should().BeFalse();
        }
예제 #7
0
        public void Returns_property_attributes_if_any()
        {
            // Arrange
            var source   = new ClassWithPropertiesOnly();
            var property = source.Property(o => o.StringPropertyWithGetSet);

            attributeProviderMock
            .GetAttributes(property)
            .Returns(Enumerable.Empty <Attribute>());

            IPropertyAccessor sut = sutFactory.Create(property);

            // Act
            var notPresent = sut.Attributes;

            // Assert
            AssertionExtensions.Should(notPresent).BeEmpty();
        }