public void GetPropertyOwner_ReturnsTypeDescriptor()
        {
            var data               = new Dictionary <string, object>();
            var typeDescriptor     = new DictionaryTypeDescriptor(data);
            var propertyDescriptor = new MockPropertyDescriptor();

            typeDescriptor.GetPropertyOwner(propertyDescriptor).Should().Be(typeDescriptor);
        }
        public void GetPropertyOwner_ReturnsTypeDescriptor()
        {
            IDictionary<string, object> data = new Dictionary<string, object>();
            DictionaryTypeDescriptor typeDescriptor = new DictionaryTypeDescriptor(data);
            PropertyDescriptor propertyDescriptor = new MockPropertyDescriptor();

            Assert.That(typeDescriptor.GetPropertyOwner(propertyDescriptor), Is.EqualTo(typeDescriptor));
        }
        public void ComponentType_ReturnsResultOfDescriptorComponentType()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            Type type = typeof(string);
            mockDescriptor.ComponentTypeResult = type;
            Assert.That(dynamicDescriptor.ComponentType, Is.EqualTo(type));
        }
        public void Category_NoOverride_ReturnsDescriptorValue()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.CategoryResult = "Base";

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            Assert.That(dynamicDescriptor.Category, Is.EqualTo("Base"));
        }
Exemple #5
0
        public void Category_NoOverride_ReturnsDescriptorValue()
        {
            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.CategoryResult = "Base";

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.Category.Should().Be("Base");
        }
Exemple #6
0
        public void DisplayName_NoOverride_ReturnsDescriptorValue()
        {
            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.DisplayNameResult = "Base";

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.DisplayName.Should().Be("Base");
        }
Exemple #7
0
        public void IsReadOnly_NoOverride_ReturnsDescriptorValue(bool value)
        {
            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.IsReadOnlyResult = value;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.IsReadOnly.Should().Be(value);
        }
Exemple #8
0
        public void PropertyType_ReturnsResultOfDescriptorPropertyType()
        {
            var mockDescriptor    = new MockPropertyDescriptor();
            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            var type = typeof(string);

            mockDescriptor.PropertyTypeResult = type;
            dynamicDescriptor.PropertyType.Should().Be(type);
        }
        public void Converter_NoOverride_ReturnsDescriptorValue()
        {
            TypeConverter converter = new TypeConverter();

            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.ConverterResult = converter;

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            Assert.That(dynamicDescriptor.Converter, Is.EqualTo(converter));
        }
Exemple #10
0
        public void ResetValue_CallsDescriptorResetValue()
        {
            var mockDescriptor    = new MockPropertyDescriptor();
            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            var component = new object();

            dynamicDescriptor.ResetValue(component);
            mockDescriptor.ResetValueComponent.Should().Be(component);
            mockDescriptor.ResetValueCalled.Should().BeTrue();
        }
Exemple #11
0
        public void Converter_NoOverride_ReturnsDescriptorValue()
        {
            var converter = new TypeConverter();

            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.ConverterResult = converter;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.Converter.Should().Be(converter);
        }
Exemple #12
0
        public void GetValue_ReturnsResultOfDescriptorGetValue()
        {
            var mockDescriptor    = new MockPropertyDescriptor();
            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            var component = new object();
            var result    = new object();

            mockDescriptor.GetValueResult = result;
            dynamicDescriptor.GetValue(component).Should().Be(result);
            mockDescriptor.GetValueComponent.Should().Be(component);
        }
Exemple #13
0
        public void GetEditor_NoOverride_ReturnsDescriptorValue()
        {
            var baseEditor = new MockUITypeEditor();

            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.GetEditorResult = baseEditor;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.GetEditor(typeof(MockUITypeEditor)).Should().Be(baseEditor);
        }
Exemple #14
0
        public void Description_Override_ReturnsOverrideValue()
        {
            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.DescriptionResult = "Base";

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.SetDescription("Override");

            dynamicDescriptor.Description.Should().Be("Override");
        }
Exemple #15
0
        public void IsReadOnly_Override_ReturnsOverrideValue(bool descriptorValue, bool overrideValue)
        {
            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.IsReadOnlyResult = descriptorValue;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.SetReadOnly(overrideValue);

            dynamicDescriptor.IsReadOnly.Should().Be(overrideValue);
        }
        public void CanResetValue_ReturnsResultOfDescriptorCanResetValue()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            object component = new object();

            mockDescriptor.CanResetValueResult = true;
            Assert.That(dynamicDescriptor.CanResetValue(component), Is.True);
            Assert.That(mockDescriptor.CanResetValueComponent, Is.EqualTo(component));

            mockDescriptor.CanResetValueResult = false;
            Assert.That(dynamicDescriptor.CanResetValue(component), Is.False);
            Assert.That(mockDescriptor.CanResetValueComponent, Is.EqualTo(component));
        }
Exemple #17
0
        public void CanResetValue_ReturnsResultOfDescriptorCanResetValue()
        {
            var mockDescriptor    = new MockPropertyDescriptor();
            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            var component = new object();

            mockDescriptor.CanResetValueResult = true;
            dynamicDescriptor.CanResetValue(component).Should().BeTrue();
            mockDescriptor.CanResetValueComponent.Should().Be(component);

            mockDescriptor.CanResetValueResult = false;
            dynamicDescriptor.CanResetValue(component).Should().BeFalse();
            mockDescriptor.CanResetValueComponent.Should().Be(component);
        }
Exemple #18
0
        public void Converter_Override_ReturnsOverrideValue()
        {
            var converterBase     = new TypeConverter();
            var converterOverride = new TypeConverter();

            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.ConverterResult = converterBase;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.SetConverter(converterOverride);

            dynamicDescriptor.Converter.Should().Be(converterOverride);
        }
Exemple #19
0
        public void GetEditor_MultipleOverrides_ReturnsMostRecentOverrideValue()
        {
            var baseEditor      = new MockUITypeEditor();
            var overrideEditor1 = new MockUITypeEditor();
            var overrideEditor2 = new MockUITypeEditor();

            var mockDescriptor = new MockPropertyDescriptor();

            mockDescriptor.GetEditorResult = baseEditor;

            var dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            dynamicDescriptor.SetEditor(typeof(MockUITypeEditor), overrideEditor1);
            dynamicDescriptor.SetEditor(typeof(MockUITypeEditor), overrideEditor2);

            dynamicDescriptor.GetEditor(typeof(MockUITypeEditor)).Should().Be(overrideEditor2);
        }
        public void GetEditor_Override_ReturnsOverrideValue()
        {
            MockUITypeEditor baseEditor = new MockUITypeEditor();
            MockUITypeEditor overrideEditor = new MockUITypeEditor();

            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.GetEditorResult = baseEditor;

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);
            dynamicDescriptor.SetEditor(typeof(MockUITypeEditor), overrideEditor);

            Assert.That(dynamicDescriptor.GetEditor(typeof(MockUITypeEditor)), Is.EqualTo(overrideEditor));
        }
        public void GetValue_ReturnsResultOfDescriptorGetValue()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            object component = new object();
            object result = new object();

            mockDescriptor.GetValueResult = result;
            Assert.That(dynamicDescriptor.GetValue(component), Is.EqualTo(result));
            Assert.That(mockDescriptor.GetValueComponent, Is.EqualTo(component));
        }
        public void IsReadOnly_NoOverride_ReturnsDescriptorValue(bool value)
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.IsReadOnlyResult = value;

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            Assert.That(dynamicDescriptor.IsReadOnly, Is.EqualTo(value));
        }
        public void IsReadOnly_Override_ReturnsOverrideValue(bool descriptorValue, bool overrideValue)
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.IsReadOnlyResult = descriptorValue;

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);
            dynamicDescriptor.SetReadOnly(overrideValue);

            Assert.That(dynamicDescriptor.IsReadOnly, Is.EqualTo(overrideValue));
        }
        public void DisplayName_Override_ReturnsOverrideValue()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.DisplayNameResult = "Base";

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);
            dynamicDescriptor.SetDisplayName("Override");

            Assert.That(dynamicDescriptor.DisplayName, Is.EqualTo("Override"));
        }
        public void SetValue_CallsDescriptorSetValue()
        {
            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);

            object component = new object();
            object value = new object();
            dynamicDescriptor.SetValue(component, value);
            Assert.That(mockDescriptor.SetValueComponent, Is.EqualTo(component));
            Assert.That(mockDescriptor.SetValueValue, Is.EqualTo(value));
            Assert.That(mockDescriptor.SetValueCalled, Is.True);
        }
        public void Converter_Override_ReturnsOverrideValue()
        {
            TypeConverter converterBase = new TypeConverter();
            TypeConverter converterOverride = new TypeConverter();

            MockPropertyDescriptor mockDescriptor = new MockPropertyDescriptor();
            mockDescriptor.ConverterResult = converterBase;

            DynamicPropertyDescriptor dynamicDescriptor = new DynamicPropertyDescriptor(mockDescriptor);
            dynamicDescriptor.SetConverter(converterOverride);

            Assert.That(dynamicDescriptor.Converter, Is.EqualTo(converterOverride));
        }