public void ListViewItemConverter_ConvertTo_InstanceDescriptor_ReturnsExpected(ListViewItem value, Type[] parameterTypes, object[] arguments)
        {
            var converter = new ListViewItemConverter();
            InstanceDescriptor descriptor = Assert.IsType <InstanceDescriptor>(converter.ConvertTo(value, typeof(InstanceDescriptor)));

            Assert.Equal(typeof(ListViewItem).GetConstructor(parameterTypes), descriptor.MemberInfo);
            Assert.Equal(arguments, descriptor.Arguments);
        }
示例#2
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// listviewitemconverter.ConvertTo<int>(context, culture, value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this ListViewItemConverter listviewitemconverter, System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value)
        {
            if (listviewitemconverter == null)
            {
                throw new ArgumentNullException("listviewitemconverter");
            }

            return((T)listviewitemconverter.ConvertTo(context, culture, value, typeof(T)));
        }
示例#3
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo<int>(value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this ListViewItemConverter typeconverter, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(value, typeof(T)));
        }
        public void ListViewItemConverter_ConvertTo_InvalidDestinationType_ThrowsNotSupportedException(Type destinationType)
        {
            var converter = new ListViewItemConverter();

            Assert.Throws <NotSupportedException>(() => converter.ConvertTo(new ListViewItem(), destinationType));
        }
        public void ListViewItemConverter_ConvertTo_ValueNotThrowsNotSupportedException()
        {
            var converter = new ListViewItemConverter();

            Assert.Throws <NotSupportedException>(() => converter.ConvertTo(1, typeof(InstanceDescriptor)));
        }
        public void ListViewItemConverter_ConvertTo_NullDestinationType_ThrowsArgumentNullException()
        {
            var converter = new ListViewItemConverter();

            Assert.Throws <ArgumentNullException>("destinationType", () => converter.ConvertTo(new object(), null));
        }
        public void ListViewItemConverter_ConvertTo_String_ReturnsExpected(object value, string expected)
        {
            var converter = new ListViewItemConverter();

            Assert.Equal(expected, converter.ConvertTo(value, typeof(string)));
        }