Ejemplo n.º 1
0
        public void PropertiesTab_GetProperties_InvokeObjectCustomAttributesNullContext_ReturnsExpected()
        {
            var tab = new PropertiesTab();
            PropertyDescriptorCollection properties = tab.GetProperties(null, new ClassWithDefaultProperty(), new Attribute[] { new BrowsableAttribute(false) });

            Assert.Equal(1, properties.Count);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.NotBrowsableProperty)]);
        }
Ejemplo n.º 2
0
        public void PropertiesTab_GetProperties_InvokeObjectNullAttributes_ReturnsExpected()
        {
            var tab = new PropertiesTab();
            PropertyDescriptorCollection properties = tab.GetProperties(new ClassWithDefaultProperty(), null);

            Assert.Equal(2, properties.Count);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.Value)]);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.BrowsableProperty)]);
        }
Ejemplo n.º 3
0
        public void PropertiesTab_GetProperties_InvokeObjectEmptyAttributesNullContext_ReturnsExpected()
        {
            var tab = new PropertiesTab();
            PropertyDescriptorCollection properties = tab.GetProperties(null, new ClassWithDefaultProperty(), Array.Empty <Attribute>());

            Assert.Equal(3, properties.Count);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.Value)]);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.NotBrowsableProperty)]);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.BrowsableProperty)]);
        }
Ejemplo n.º 4
0
        public void PropertiesTab_GetProperties_InvokeObjectNullAttributesCustomContextCustomTypeConverter_ReturnsExpected()
        {
            var tab = new PropertiesTab();
            var mockTypeDescriptorContext = new Mock <ITypeDescriptorContext>(MockBehavior.Strict);

            mockTypeDescriptorContext
            .Setup(c => c.PropertyDescriptor)
            .Returns(TypeDescriptor.GetProperties(typeof(CustomTypeConverterParentClass))[0])
            .Verifiable();
            PropertyDescriptorCollection properties = tab.GetProperties(mockTypeDescriptorContext.Object, new ClassWithDefaultProperty(), null);

            Assert.Equal(1, properties.Count);
            Assert.NotNull(properties[nameof(ClassWithNameProperty.Name)]);
            mockTypeDescriptorContext.Verify(c => c.PropertyDescriptor, Times.Exactly(2));
        }
Ejemplo n.º 5
0
        public void PropertiesTab_GetProperties_InvokeObjectNullAttributesNullPropertyContextPropertiesSupported_ReturnsExpected()
        {
            var tab = new PropertiesTab();
            var mockTypeDescriptorContext = new Mock <ITypeDescriptorContext>(MockBehavior.Strict);

            mockTypeDescriptorContext
            .Setup(c => c.PropertyDescriptor)
            .Returns((PropertyDescriptor)null)
            .Verifiable();
            PropertyDescriptorCollection properties = tab.GetProperties(mockTypeDescriptorContext.Object, new ClassWithDefaultProperty(), null);

            Assert.Equal(2, properties.Count);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.Value)]);
            Assert.NotNull(properties[nameof(ClassWithDefaultProperty.BrowsableProperty)]);
            mockTypeDescriptorContext.Verify(c => c.PropertyDescriptor, Times.Once());
        }
Ejemplo n.º 6
0
        public void PropertiesTab_GetProperties_InvokeNullObject_ReturnsExpected()
        {
            var tab = new PropertiesTab();

            Assert.Empty(tab.GetProperties(null));
        }