Exemple #1
0
        public void ArrayEditor_GetDisplayText_ValueDoesntMatchCollectionType_ThrowsTargetException()
        {
            var editor = new SubArrayEditor(typeof(ClassWithStringDefaultProperty));
            TargetInvocationException ex = Assert.Throws <TargetInvocationException>(() => editor.GetDisplayText(new ClassWithNonStringDefaultProperty()));

            Assert.IsType <TargetException>(ex.InnerException);
        }
Exemple #2
0
        public void ArrayEditor_SetItems_NullCollectionItemType_ThrowsArgumentNullException(Type type)
        {
            var editor = new SubArrayEditor(type);

            Assert.Null(editor.CollectionItemType);
            Assert.Throws <ArgumentNullException>("elementType", () => editor.SetItems(null, Array.Empty <object>()));
            Assert.Throws <ArgumentNullException>("elementType", () => editor.SetItems(Array.Empty <object>(), Array.Empty <object>()));
        }
Exemple #3
0
        public void ArrayEditor_SetItems_InvokeArray_ReturnsCopy(object editValue, object[] value, int[] expected)
        {
            var editor = new SubArrayEditor(typeof(int[]));

            int[] result = Assert.IsType <int[]>(editor.SetItems(editValue, value));
            Assert.NotSame(value, expected);
            Assert.Equal(expected, result);
        }
Exemple #4
0
        public void ArrayEditor_CanRemoveInstance_InheritanceAttribute_ReturnsExpected(InheritanceAttribute attribute, bool expected)
        {
            var component = new Component();

            TypeDescriptor.AddAttributes(component, attribute);
            var editor = new SubArrayEditor(null);

            Assert.Equal(expected, editor.CanRemoveInstance(component));
        }
Exemple #5
0
        public void ArrayEditor_GetItems_Invoke_ReturnsExpected(object editValue, object[] expected)
        {
            var editor = new SubArrayEditor(null);

            object[] items = editor.GetItems(editValue);
            Assert.Equal(expected, items);
            Assert.IsType(expected.GetType(), items);
            Assert.NotSame(editValue, items);
        }
Exemple #6
0
        public void ArrayEditor_Ctor_NullType()
        {
            var editor = new SubArrayEditor(null);

            Assert.Null(editor.CollectionItemType);
            Assert.Null(editor.CollectionType);
            Assert.Null(editor.Context);
            Assert.Equal("net.ComponentModel.CollectionEditor", editor.HelpTopic);
            Assert.False(editor.IsDropDownResizable);
            Assert.Equal(new Type[] { null }, editor.NewItemTypes);
        }
Exemple #7
0
        public void ArrayEditor_Ctor_Type(Type type, Type expectedItemType)
        {
            var editor = new SubArrayEditor(type);

            Assert.Equal(expectedItemType, editor.CollectionItemType);
            Assert.Same(editor.CollectionItemType, editor.CollectionItemType);
            Assert.Equal(type, editor.CollectionType);
            Assert.Null(editor.Context);
            Assert.Equal("net.ComponentModel.CollectionEditor", editor.HelpTopic);
            Assert.False(editor.IsDropDownResizable);
            Assert.Equal(new Type[] { expectedItemType }, editor.NewItemTypes);
        }
Exemple #8
0
        public void ArrayEditor_CanSelectMultipleInstances_Invoke_ReturnsFalse()
        {
            var editor = new SubArrayEditor(null);

            Assert.True(editor.CanSelectMultipleInstances());
        }
Exemple #9
0
        public void ArrayEditor_CanRemoveInstance_Invoke_ReturnsExpected(object value)
        {
            var editor = new SubArrayEditor(null);

            Assert.True(editor.CanRemoveInstance(value));
        }
Exemple #10
0
        public void ArrayEditor_SetItems_InvokeNonArrayValue_ReturnsExpected(object editValue, object[] value, object expected)
        {
            var editor = new SubArrayEditor(typeof(int[]));

            Assert.Same(expected, editor.SetItems(editValue, value));
        }
Exemple #11
0
        public void ArrayEditor_GetDisplayText_Invoke_ReturnsExpected(Type type, object value, string expected)
        {
            var editor = new SubArrayEditor(type);

            Assert.Equal(expected, editor.GetDisplayText(value));
        }