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 SetUp() { binder = (StandardModelBinder)StandardModelBinder.Basic(); context = new InMemoryBindingContext(); result = null; }
public void return_the_value_from_the_connectionStrings_section() { var context = new InMemoryBindingContext().WithPropertyValue(connectionStringKey); object result = family.Build(null, expandProp).Convert(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).Convert(value); result.ShouldEqual("foo"); }
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 should_convert_nonnull_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("99"); value.ForProperty(nullIntProp, c => { reg.FindConverter(nullIntProp).Convert(c).ShouldEqual(99); }); }
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(); }); }
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 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(); }
public void SetUp() { context = new InMemoryBindingContext(); theConverterRegistry = new ValueConverterRegistry(new IConverterFamily[0], new ConverterLibrary()); propertyBinder = new ConversionPropertyBinder(theConverterRegistry); }