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_Ctor_Default()
        {
            var tab = new PropertiesTab();

            Assert.NotNull(tab.Bitmap);
            Assert.Same(tab.Bitmap, tab.Bitmap);
            Assert.Null(tab.Components);
            Assert.Equal("vs.properties", tab.HelpKeyword);
            Assert.NotEqual(tab.TabName, tab.HelpKeyword);
            Assert.NotEmpty(tab.TabName);
        }
Ejemplo n.º 5
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.º 6
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.º 7
0
        public void PropertiesTab_GetProperties_InvokeNullObject_ReturnsExpected()
        {
            var tab = new PropertiesTab();

            Assert.Empty(tab.GetProperties(null));
        }
Ejemplo n.º 8
0
        public void PropertiesTab_GetDefaultProperty_InvokeNullComponent_ReturnsExpected()
        {
            var tab = new PropertiesTab();

            Assert.Null(tab.GetDefaultProperty(null));
        }
Ejemplo n.º 9
0
        public void PropertiesTab_GetDefaultProperty_InvokeWithDefaultProperty_ReturnsExpected()
        {
            var tab = new PropertiesTab();

            Assert.Equal("Value", tab.GetDefaultProperty(new ClassWithDefaultProperty()).Name);
        }
Ejemplo n.º 10
0
        public void PropertiesTab_GetDefaultProperty_InvokeWithoutDefaultProperty_ReturnsExpected()
        {
            var tab = new PropertiesTab();

            Assert.Null(tab.GetDefaultProperty(new ClassWithoutDefaultProperty()));
        }