public void resolve_to_full_paths_for_settings_marked_for_local_path_resolution()
        {
            var value = new InMemoryBindingContext().WithPropertyValue("~/App_Data/file.txt");

            object result = family.Build(null, expandProp).Convert(value);
            result.ShouldEqual(webAppFolder + "\\App_Data\\file.txt");
        }
Exemplo n.º 2
0
        public void creating_a_prefixed_context_brings_the_logger_with_it()
        {
            var context = new InMemoryBindingContext();
            var prefixed = context.PrefixWith("something");

            prefixed.Logger.ShouldBeTheSameAs(context.Logger);
        }
Exemplo n.º 3
0
        public void resolve_to_full_paths_for_settings_marked_for_local_path_resolution()
        {
            var value = new InMemoryBindingContext().WithPropertyValue("~/file.txt");

            object result = family.Build(null, expandProp)(value);

            result.ShouldEqual(webAppFolder + @"/file.txt");
        }
Exemplo n.º 4
0
        public void return_the_original_value_if_the_connection_string_doesnt_exist()
        {
            var value = new InMemoryBindingContext().WithPropertyValue("foo");

            object result = family.Build(null, expandProp)(value);

            result.ShouldEqual("foo");
        }
Exemplo n.º 5
0
        public void return_the_value_from_the_connectionStrings_section()
        {
            var context = new InMemoryBindingContext().WithPropertyValue(connectionStringKey);

            object result = family.Build(null, expandProp)(context);

            result.ShouldEqual(actualConnectionString);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public void Setup()
        {
            context = new InMemoryBindingContext();
            var container      = StructureMapContainerFacility.GetBasicFubuContainer();
            var objectResolver = container.GetInstance <ObjectResolver>();

            context.Container.Configure(x => x.For <IObjectResolver>().Use(objectResolver));
            propertyBinder = new CollectionPropertyBinder(new DefaultCollectionTypeProvider());
        }
 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");
     value.ForProperty(nullIntProp, c =>
     {
         reg.FindConverter(nullIntProp).Convert(c).ShouldEqual(99);
     });
 }
        public void Setup()
        {
            context = new InMemoryBindingContext();
            var objectResolver = ObjectResolver.Basic();
            context.RegisterService<IObjectResolver>(objectResolver);
            context.RegisterService<ISmartRequest>(new InMemorySmartRequest());
            context.RegisterService<IRequestData>(new InMemoryRequestData());

            propertyBinder = new CollectionPropertyBinder(new DefaultCollectionTypeProvider());
        }
Exemplo n.º 10
0
        public void SetUp()
        {
            binders = new List <IModelBinder>();
            data    = new InMemoryBindingContext();

            setupContext();

            var container = StructureMapContainerFacility.GetBasicFubuContainer(x => binders.Each(b => x.For <IModelBinder>().Add(b)));

            resolver = container.GetInstance <ObjectResolver>();
        }
Exemplo n.º 11
0
        protected override void beforeEach()
        {
            result = new BindResult
            {
                Value = new object()
            };
            context = new InMemoryBindingContext();
            MockFor <ObjectResolver>().Expect(x => x.BindModel(typeof(BinderTarget), context)).Return(result);

            ClassUnderTest.BindModel(typeof(BinderTarget), context).ShouldBeTheSameAs(result);
        }
Exemplo n.º 12
0
        public void can_accept_the_property_name_and_treat_it_as_true()
        {
            PropertyInfo property = ReflectionHelper.GetProperty<DummyClass>(c => c.Hungry);
            var context = new InMemoryBindingContext();
            context["Hungry"] = "Hungry";

            ValueConverter converter = new BooleanFamily().Build(null, property);
            context.ForProperty(property, x =>
            {
                converter.Convert(context).As<bool>().ShouldBeTrue();
            });
        }
Exemplo n.º 13
0
        public void SetUp()
        {
            // Lots of stuff to put together, so I'm just using a minimalistic
            // container to do it for me because I'm lazy -- JDM 2/12/2010
            IContainer container = StructureMapContainerFacility.GetBasicFubuContainer();

            binder = container.GetInstance <StandardModelBinder>();

            context = new InMemoryBindingContext();

            result = null;
        }
Exemplo n.º 14
0
        public void can_accept_the_property_name_and_treat_it_as_true()
        {
            PropertyInfo property = ReflectionHelper.GetProperty <DummyClass>(c => c.Hungry);
            var          context  = new InMemoryBindingContext();

            context["Hungry"] = "Hungry";

            ValueConverter converter = new BooleanFamily().Build(null, property);

            context.ForProperty(property, x =>
            {
                converter(context).As <bool>().ShouldBeTrue();
            });
        }
        public void expand_environment_variables_for_settings_marked_for_expansion()
        {
            string expandedVariable = Environment.GetEnvironmentVariable("SystemRoot");
            var context = new InMemoryBindingContext();
            context[expandProp.Name] = "%SystemRoot%\\foo";

            bool wasCalled = false;
            ValueConverter converter = _family.Build(null, expandProp);
            context.ForProperty(expandProp, x =>
            {
                wasCalled = true;

                converter.Convert(context).ShouldEqual(expandedVariable + @"\foo");
            });

            wasCalled.ShouldBeTrue();
        }
Exemplo n.º 16
0
        private bool WithValue(string value)
        {
            PropertyInfo property = ReflectionHelper.GetProperty <BooleanFamilyTester.DummyClass>(c => c.Hungry);
            var          context  = new InMemoryBindingContext();

            context["Hungry"] = value;

            var convertedValue = false;

            ValueConverter converter = new BooleanFamily().Build(null, property);

            context.ForProperty(property, x =>
            {
                convertedValue = converter(context).As <bool>();
            });

            return(convertedValue);
        }
Exemplo n.º 17
0
        public void expand_environment_variables_for_settings_marked_for_expansion()
        {
            string expandedVariable = Environment.GetEnvironmentVariable("SystemRoot");
            var    context          = new InMemoryBindingContext();

            context[expandProp.Name] = "%SystemRoot%\\foo";

            bool           wasCalled = false;
            ValueConverter converter = _family.Build(null, expandProp);

            context.ForProperty(expandProp, () =>
            {
                wasCalled = true;

                converter(context).ShouldEqual(expandedVariable + @"\foo");
            });

            wasCalled.ShouldBeTrue();
        }
Exemplo n.º 18
0
        private bool WithValue(string value)
        {
            PropertyInfo property = ReflectionHelper.GetProperty<BooleanFamilyTester.DummyClass>(c => c.Hungry);
            var context = new InMemoryBindingContext();
            context["Hungry"] = value;

            var convertedValue = false;

            ValueConverter converter = new BooleanFamily().Build(null, property);
            context.ForProperty(property, x =>
            {
                convertedValue = converter.Convert(context).As<bool>();
            });

            return convertedValue;
        }
Exemplo n.º 19
0
 public void SetUp()
 {
     context        = new InMemoryBindingContext();
     propertyBinder = new ConversionPropertyBinder(new ValueConverterRegistry(new IConverterFamily[0]));
 }
 public void SetUp()
 {
     context = new InMemoryBindingContext();
     theConverterRegistry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary());
     propertyBinder = new ConversionPropertyBinder(theConverterRegistry);
 }