public void return_the_original_value_if_the_connection_string_doesnt_exist() { BindingScenario <TestSettings> .Build(x => { x.Data(o => o.DefaultPath, "foo"); }).DefaultPath.ShouldEqual("foo"); }
public void return_the_value_from_the_connectionStrings_section() { BindingScenario <TestSettings> .Build(x => { x.Data(o => o.DefaultPath, connectionStringKey); }).DefaultPath.ShouldEqual(actualConnectionString); }
public void should_convert_nonnull_values_for_nullable_types() { BindingScenario <Target> .Build(x => { x.Data(o => o.NullInt, 99); }).NullInt.ShouldEqual(99); }
public void convert_returns_the_context_property_value() { BindingScenario <MyModel> .Build(x => { x.Data(o => o.ObjectProperty, "123"); }).ObjectProperty.ShouldEqual("123"); }
public void do_a_primitive_list() { BindingScenario <HybridHolder> .Build(x => { x.Data("Ages", "38,8,32"); }).Ages.ShouldHaveTheSameElementsAs(38, 8, 32); }
public void should_build() { using (new ScopedCulture(CultureInfo.CreateSpecificCulture("en-us"))) { BindingScenario <PropertyHolder> .Build(x => x.Data("Property", "1,000.001")) .Property.ShouldEqual(1000.001m); } }
public void apply_collection_binding_when_it_is_one_value_should_delegate_to_the_conversion() { var guys = BindingScenario <HybridHolder> .Build(x => { x.Data(@" Guys=Jeremy:38,Max:8 "); }).Guys; guys.ShouldHaveTheSameElementsAs(new HybridGuy("Jeremy", 38), new HybridGuy("Max", 8)); }
public void apply_collection_that_can_be_converted_as_individual_values() { var guys = BindingScenario <HybridHolder> .Build(x => { x.Data(@" Guys[0]Name=Jeremy Guys[0]Age=38 Guys[1]Name=Max Guys[1]Age=8 "); }).Guys; guys.ShouldHaveTheSameElementsAs(new HybridGuy("Jeremy", 38), new HybridGuy("Max", 8)); }
public void SetUp() { var theHttpRequest = new CurrentChain(new BehaviorChain(), new Dictionary <string, object>()); theExpectedHash = ResourceHash.For(theHttpRequest); FubuApplication.SetupNamingStrategyForHttpHeaders(); theEtagRequest = BindingScenario <ETaggedRequest> .Build(x => { x.Service <ICurrentChain>(theHttpRequest); x.Data("If-None-Match", "12345"); }); }
public void should_resolve_the_requested_model_with_the_first_binder_that_matches() { binder1 = MockRepository.GenerateMock <IModelBinder>(); binder2 = MockRepository.GenerateMock <IModelBinder>(); binder1.Stub(x => x.Matches(typeof(BinderTarget))).Return(false); binder2.Stub(x => x.Matches(typeof(BinderTarget))).Return(false); expectedResult = new BinderTarget(); matchingBinder = new StubBinder(expectedResult); BindingScenario <BinderTarget> .Build(x => { x.Registry.Add(binder1); x.Registry.Add(binder2); x.Registry.Add(matchingBinder); }).ShouldBeTheSameAs(expectedResult); }
public void should_throw_fubu_exception_2201() { matchingBinder = MockRepository.GenerateStub <IModelBinder>(); matchingBinder.Stub(x => x.Matches(_type)).Return(true); matchingBinder.Stub(x => x.Bind(_type, null)).IgnoreArguments().Throw(new Exception("fake message")); var exception = Exception <FubuException> .ShouldBeThrownBy(() => { BindingScenario <BinderTarget> .Build(x => { x.Registry.Add(matchingBinder); }); }); exception.ShouldNotBeNull().Message.ShouldEqual( "FubuCore Error 2201: \nFatal error while binding model of type {0}. See inner exception" .ToFormat(_type.AssemblyQualifiedName)); }
public void existing_collection_is_not_discarded() { var originalList = new List <LocalityViewModel> { new LocalityViewModel { ZipCode = "previously_set_zipcode" } }; var model = BindingScenario <AddressViewModel> .Build(x => { x.Model = new AddressViewModel() { Localities = originalList }; x.Data("Localities[0]ZipCode", "84115"); }); model.Localities.Select(x => x.ZipCode).ShouldHaveTheSameElementsAs("previously_set_zipcode", "84115"); }
public void should_convert_null_values_for_nullable_types() { BindingScenario <Target> .Build(x => { }).NullInt.ShouldBeNull(); }