Exemple #1
0
        public void SetValue_Always_DelegateToWrappedPropertyDescriptor()
        {
            // Setup
            const double originalPropertyValue = 1.1;
            const double newValue  = 2.2;
            var          component = new SomeTestClass
            {
                SomeEditableProperty = originalPropertyValue
            };

            PropertyDescriptorCollection properties     = TypeDescriptor.GetProperties(component);
            PropertyDescriptor           getSetProperty = properties[0];

            getSetProperty.SetValue(component, newValue);
            double expectedPropertyValueAfterSet = component.SomeEditableProperty;

            var wrappedProperty = new ReadOnlyPropertyDescriptorDecorator(getSetProperty);

            component.SomeEditableProperty = originalPropertyValue;

            // Call
            wrappedProperty.SetValue(component, newValue);

            // Assert
            Assert.AreEqual(expectedPropertyValueAfterSet, component.SomeEditableProperty);
        }