Exemple #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)]);
        }
Exemple #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)]);
        }
Exemple #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)]);
        }
Exemple #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);
        }
Exemple #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));
        }
Exemple #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());
        }
Exemple #7
0
        public void PropertiesTab_GetProperties_InvokeNullObject_ReturnsExpected()
        {
            var tab = new PropertiesTab();

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

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

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

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