public void empty_route_string_must_be_null() { string input = string.Empty; var interpreter = new RouteInput(); Assert.Null(interpreter.Translate(input)); }
public void route_translation_invalid_format_must_be_null() { string input = "asdfasdf8823djdDD33--"; var interpreter = new RouteInput(); Assert.Null(interpreter.Translate(input)); }
public void route_translation_additional_property_must_be_initialized() { string input = "GRU,CDG,10"; var interpreter = new RouteInput(); Assert.NotNull(interpreter.Translate(input)); }
public void route_translation_missing_property_must_be_null() { string input = "GRU,CDG"; var interpreter = new RouteInput(); Assert.Null(interpreter.Translate(input)); }
public void create_url_with_input_model_and_no_default_value_specified_for_required_input() { var url = new RouteInput <SampleViewModelWithInputs>("test/edit/{RequiredInput}"); url.AddRouteInput(x => x.RequiredInput); Exception <FubuException> .ShouldBeThrownBy(() => url.CreateUrlFromInput(new SampleViewModelWithInputs())); }
public void create_url_for_a_route_with_two_parameters() { var url = new RouteInput <SampleViewModel>("my/sample/{InPath}/{AlsoInPath}"); url.AddRouteInput(x => x.InPath); url.AddRouteInput(x => x.AlsoInPath); url.Parent.ToRoute().Url.ShouldEqual("my/sample/{InPath}/{AlsoInPath}"); }
public RouteInput RouteInputFor(Expression <Func <T, object> > expression) { Accessor accessor = ReflectionHelper.GetAccessor(expression); var input = new RouteInput(accessor); _modifiers.Add(r => r.AddRouteInput(input, true)); return(input); }
public void create_url_with_input_model_and_encoded_variable() { var url = new RouteInput <SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.CreateUrlFromInput(new SampleViewModel { InPath = "abc/def&ghi=jkl" }).ShouldEqual("test/edit/abc%2Fdef%26ghi%3Djkl"); }
public void route_input_should_substitute_method() { SingleProperty accessor = SingleProperty.Build <SampleViewModel>(x => x.InPath); var viewModel = new SampleViewModel { InPath = "5" }; var routeInput = new RouteInput(accessor); routeInput.Substitute(viewModel, "test/edit/{InPath}").ShouldEqual("test/edit/5"); }
public void create_two_default_values_for_a_route() { var url = new RouteInput <SampleViewModel>("my/sample"); url.AddRouteInput(x => x.InPath); url.AddRouteInput(x => x.AlsoInPath); url.RouteInputFor("InPath").DefaultValue = "something"; url.RouteInputFor("AlsoInPath").DefaultValue = "something else"; Route route = url.Parent.ToRoute(); route.Defaults.Count().ShouldEqual(2); }
public void create_url_will_escape_the_url_with_parameters() { var url = new RouteInput <SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); var parameters = new RouteParameters <SampleViewModel>(); parameters[x => x.InPath] = "some text"; url.CreateUrlFromParameters(parameters).ShouldBe("test/edit/some%20text"); }
public void will_not_use_query_string_if_there_is_no_value() { var url = new RouteInput <SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.AddQueryInput(x => x.InQueryString); url.CreateUrlFromInput(new SampleViewModel { InPath = "5", InQueryString = null }).ShouldEqual("test/edit/5"); }