Exemple #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);
        }
Exemple #2
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);
        }
Exemple #3
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();
        }
Exemple #4
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();
        }