Пример #1
0
        public void PropertyHelper_ReturnsGetterDelegate()
        {
            // Arrange
            var anonymous = new { bar = "baz" };
            var property  = PropertyHelper.GetPropertyAccessors(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper.PropertyAccessor(property);

            // Assert
            Assert2.NotNull(helper.ValueGetter);
            Assert2.Equal("baz", helper.ValueGetter(anonymous));
        }
Пример #2
0
        public void PropertyHelper_ReturnsValueCorrectly_ForValueTypes()
        {
            // Arrange
            var anonymous = new { foo = 32 };
            var property  = PropertyHelper.GetPropertyAccessors(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper.PropertyAccessor(property);

            // Assert
            Assert2.Equal("foo", helper.Name);
            Assert2.Equal(32, helper.GetValue(anonymous));
        }
Пример #3
0
        public void PropertyHelper_ReturnsValueCorrectly()
        {
            // Arrange
            var anonymous = new { bar = "baz" };
            var property  = PropertyHelper.GetPropertyAccessors(anonymous.GetType()).First().Property;

            // Act
            var helper = new PropertyHelper.PropertyAccessor(property);

            // Assert
            Assert2.Equal("bar", helper.Name);
            Assert2.Equal("baz", helper.GetValue(anonymous));
        }