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 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_value_from_the_connectionStrings_section() { var context = new InMemoryBindingContext().WithPropertyValue(connectionStringKey); object result = family.Build(null, expandProp)(context); result.ShouldEqual(actualConnectionString); }
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 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 treats_true_string_as_true() { PropertyInfo property = ReflectionHelper.GetProperty<DummyClass>(c => c.Hungry); var context = new InMemoryBindingContext(); context["Hungry"] = "true"; ValueConverter converter = new BooleanFamily().Build(null, property); context.ForProperty(property, () => { converter(context).As<bool>().ShouldBeTrue(); }); }
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, () => { wasCalled = true; converter(context).ShouldEqual(expandedVariable + @"\foo"); }); wasCalled.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 var container = StructureMapContainerFacility.GetBasicFubuContainer(); binder = container.GetInstance<StandardModelBinder>(); context = new InMemoryBindingContext(); result = null; }
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 SetUp() { context = new InMemoryBindingContext(); converter = new ConversionPropertyBinder(new ValueConverterRegistry(new IConverterFamily[0])); }