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"); }
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); }
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"); }
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"); }
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); }
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 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()); }
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>(); }
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); }
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(); }); }
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; }
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(); }
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); }
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(); }
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; }
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); }