public void ReturnsCorrectType()
        {
            var    converter = new GetTypeConverter();
            object value     = "A String.";
            Type   result    = converter.Convert(value, null, null);

            Assert.Equal(value.GetType(), result);
        }
示例#2
0
        public static Type  GetSourcePropertyType(object obj, string propertyPath)
        {
            Binding binding = new Binding(propertyPath);

            binding.Mode   = BindingMode.TwoWay;
            binding.Source = obj;
            var Conv = new GetTypeConverter();

            binding.Converter = Conv;
            BindingOperations.SetBinding(_dummy, Dummy.ValueProperty, binding);
            _dummy.SetValue(Dummy.ValueProperty, 1);
            return(Conv.lastType);
        }
        public void ThrowsArgumentNullExceptionForNullValue()
        {
            var converter = new GetTypeConverter();

            Assert.Throws <ArgumentNullException>(() => converter.Convert(null, null, null));
        }