コード例 #1
0
        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();
        }
コード例 #2
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);
 }
コード例 #3
0
 public void SetUp()
 {
     var converterRegistry = new ValueConverterRegistry(new IConverterFamily[]{new EntityPropertyConverter()}, new ConverterLibrary());
     binder = new StandardModelBinder(
             new PropertyBinderCache(new IPropertyBinder[0], converterRegistry,
                                     new DefaultCollectionTypeProvider()),
             new TypeDescriptorCache());
 }
コード例 #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);
        }
コード例 #5
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();
        }
コード例 #6
0
        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);
            });
        }
コード例 #7
0
 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);
 }
コード例 #8
0
        public void SetUp()
        {
            _registry = new ValueConverterRegistry(new IConverterFamily[0]);
            _property = typeof(HttpRequestBase).GetProperty("Browser");
            _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf =>
                cf.Matches(_property)) as ASPNetObjectConversionFamily;
            _aspNetObjectConversionFamily.ShouldNotBeNull();

            _context = MockRepository.GenerateMock<IPropertyContext>();
            _propertyValue = new object();
            _context.Expect(c => c.PropertyValue).Return(_propertyValue);
        }
コード例 #9
0
        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);
            });
        }
コード例 #10
0
        public void SetUp()
        {
            _registry           = new ValueConverterRegistry(new IConverterFamily[0]);
            _property           = typeof(PropertyHolder).GetProperty("Property");
            _basicTypeConverter = _registry.Families.SingleOrDefault(cf =>
                                                                     cf.Matches(_property)) as BasicTypeConverter;
            _basicTypeConverter.ShouldNotBeNull();

            _context       = MockRepository.GenerateMock <IPropertyContext>();
            _propertyValue = "some value";
            _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(3);
        }
コード例 #11
0
        public void SetUp()
        {
            _registry          = new ValueConverterRegistry(new IConverterFamily[0]);
            _property          = typeof(PropertyHolder).GetProperty("Property");
            _numericTypeFamily = _registry.Families.FirstOrDefault(cf =>
                                                                   cf.Matches(_property)) as NumericTypeFamily;
            _numericTypeFamily.ShouldNotBeNull();

            _context       = MockRepository.GenerateMock <IPropertyContext>();
            _propertyValue = "1,000.001";
            _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(4);
        }
コード例 #12
0
        public void SetUp()
        {
            _registry = new ValueConverterRegistry(new IConverterFamily[0]);
            _property = typeof(HttpRequestBase).GetProperty("Browser");
            _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf =>
                                                                               cf.Matches(_property)) as ASPNetObjectConversionFamily;
            _aspNetObjectConversionFamily.ShouldNotBeNull();

            _context       = MockRepository.GenerateMock <IBindingContext>();
            _propertyValue = new object();
            _context.Expect(c => c.PropertyValue).Return(_propertyValue);
        }
コード例 #13
0
        public void SetUp()
        {
            _registry = new ValueConverterRegistry(new IConverterFamily[0]);
            _property = typeof(PropertyHolder).GetProperty("Property");
            _basicTypeConverter = _registry.Families.SingleOrDefault(cf =>
                cf.Matches(_property)) as BasicTypeConverter;
            _basicTypeConverter.ShouldNotBeNull();

            _context = MockRepository.GenerateMock<IBindingContext>();
            _propertyValue = "some value";
            _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(3);
        }
コード例 #14
0
        public void SetUp()
        {
            theLibrary = new ConverterLibrary();
            _registry = new ValueConverterRegistry(new IConverterFamily[0], theLibrary);
            _property = typeof (PropertyHolder).GetProperty("Property");
            _basicConverterFamily = _registry.Families.SingleOrDefault(cf =>
                                                                       cf.Matches(_property)) as BasicConverterFamily;
            _basicConverterFamily.ShouldNotBeNull();

            _context = MockRepository.GenerateMock<IPropertyContext>();
            _context.Stub(x => x.Property).Return(_property);
            _propertyValue = "some value";
            _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(3);
        }
コード例 #15
0
        public void SetUp()
        {
            _registry =
                StructureMapContainerFacility.GetBasicFubuContainer().GetInstance<IValueConverterRegistry>().As
                    <ValueConverterRegistry>();
            _property = typeof(HttpRequestBase).GetProperty("Browser");
            _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf =>
                cf.Matches(_property)) as AspNetObjectConversionFamily;
            _aspNetObjectConversionFamily.ShouldNotBeNull();

            _context = MockRepository.GenerateMock<IPropertyContext>();
            _propertyValue = new object();
            _context.Expect(c => c.PropertyValue).Return(_propertyValue);
        }
コード例 #16
0
        public void SetUp()
        {
            _registry =
                StructureMapContainerFacility.GetBasicFubuContainer().GetInstance <IValueConverterRegistry>().As
                <ValueConverterRegistry>();
            _property = typeof(HttpRequestBase).GetProperty("Browser");
            _aspNetObjectConversionFamily = _registry.Families.SingleOrDefault(cf =>
                                                                               cf.Matches(_property)) as AspNetObjectConversionFamily;
            _aspNetObjectConversionFamily.ShouldNotBeNull();

            _context       = MockRepository.GenerateMock <IPropertyContext>();
            _propertyValue = new object();
            _context.Expect(c => c.PropertyValue).Return(_propertyValue);
        }
コード例 #17
0
 public void SetUp()
 {
     context = new InMemoryBindingContext();
     theConverterRegistry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());
     propertyBinder = new ConversionPropertyBinder(theConverterRegistry);
 }
コード例 #18
0
 public void SetUp()
 {
     context = new InMemoryBindingContext();
     theConverterRegistry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());
     propertyBinder       = new ConversionPropertyBinder(theConverterRegistry);
 }
コード例 #19
0
        public void SetUp()
        {
            _registry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());
            _property = typeof (PropertyHolder).GetProperty("Property");
            _numericTypeFamily = _registry.Families.FirstOrDefault(cf =>
                                                                   cf.Matches(_property)) as NumericTypeFamily;
            _numericTypeFamily.ShouldNotBeNull();

            _context = MockRepository.GenerateMock<IPropertyContext>();
            _context.Stub(x => x.Property).Return(_property);
            _propertyValue = "1,000.001";
            _context.Expect(c => c.PropertyValue).Return(_propertyValue).Repeat.Times(4);
        }
コード例 #20
0
 public RecordingValueConverterRegistry(ValueConverterRegistry inner, Func<IDebugReport> report)
 {
     _inner = inner;
     _report = report;
 }
コード例 #21
0
 public void SetUp()
 {
     registry = new ValueConverterRegistry(new IConverterFamily[0]);
     data = new InMemoryRequestData();
     binder = new StandardModelBinder(registry, new TypeDescriptorRegistry());
     locator = MockRepository.GenerateMock<IServiceLocator>();
     result = null;
 }
コード例 #22
0
 static PropertyValue()
 {
     ConverterRegistry = new ValueConverterRegistry <TPropertyType>();
 }