public void can_find_a_converter_for_HttpPostedFileBase()
        {
            var registry = new ValueConverterRegistry(new IConverterFamily[0]);

            var property = ReflectionHelper.GetProperty<ModelWithHttpPostedFileBase>(x => x.File);
            registry.FindConverter(property).ShouldNotBeNull();
        }
 public void should_convert_nonnull_values_for_nullable_types()
 {
     PropertyInfo nullIntProp = ReflectionHelper.GetProperty<Target>(x => x.NullInt);
     var reg = new ValueConverterRegistry(new IConverterFamily[0]);
     var value = new InMemoryBindingContext().WithPropertyValue("99");
     reg.FindConverter(nullIntProp)(value).ShouldEqual(99);
 }
Exemple #3
0
        public void can_find_a_converter_for_a_system_property()
        {
            var registry = new ValueConverterRegistry(new IConverterFamily[0]);

            var property = ReflectionHelper.GetProperty <ModelWithHttpPostedFileBase>(x => x.AcceptTypes);

            registry.FindConverter(property).ShouldNotBeNull();
        }
Exemple #4
0
        public void should_convert_nonnull_values_for_nullable_types()
        {
            PropertyInfo nullIntProp = ReflectionHelper.GetProperty <Target>(x => x.NullInt);
            var          reg         = new ValueConverterRegistry(new IConverterFamily[0]);
            var          value       = new InMemoryBindingContext().WithPropertyValue("99");

            reg.FindConverter(nullIntProp)(value).ShouldEqual(99);
        }
        public void should_convert_null_values_for_nullable_types()
        {
            PropertyInfo nullIntProp = ReflectionHelper.GetProperty<Target>(x => x.NullInt);
            var reg = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());

            var value = new InMemoryBindingContext().WithPropertyValue(null);
            value.ForProperty(nullIntProp, c =>
            {
                reg.FindConverter(nullIntProp).Convert(c).ShouldEqual(null);
            });
        }
 public void should_convert_null_values_for_nullable_types()
 {
     PropertyInfo nullIntProp = ReflectionHelper.GetProperty<Target>(x => x.NullInt);
     var reg = new ValueConverterRegistry(new IConverterFamily[0]);
     var value = new RawValue
     {
         Property = nullIntProp,
         Value = null
     };
     reg.FindConverter(nullIntProp)(value).ShouldEqual(null);
 }
        public void should_convert_null_values_for_nullable_types()
        {
            PropertyInfo nullIntProp = ReflectionHelper.GetProperty <Target>(x => x.NullInt);
            var          reg         = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());

            var value = new InMemoryBindingContext().WithPropertyValue(null);

            value.ForProperty(nullIntProp, c =>
            {
                reg.FindConverter(nullIntProp).Convert(c).ShouldEqual(null);
            });
        }