public void create_url_with_input_model() { var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.CreateUrl(new SampleViewModel { InPath = "5" }).ShouldEqual("/test/edit/5"); }
public void create_url_will_escape_the_url() { var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.CreateUrl(new SampleViewModel { InPath = "some text" }).ShouldEqual("/test/edit/some%20text"); }
public void create_url_with_input_model_and_default_value_for_optional_input() { var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{OptionalInput}"); url.AddRouteInput(x => x.OptionalInput); url .CreateUrl(new SampleViewModelWithInputs { OptionalInput = "a" }) .ShouldEndWith("/test/edit/a"); }
public void create_url_with_variables_in_querystring() { var url = new RouteDefinition<SampleViewModel>("/my/sample/path"); url.AddQueryInput(x => x.InQueryString); url.CreateUrl(new SampleViewModel { InQueryString = "query" }).ShouldEqual("/my/sample/path?InQueryString=query"); }
public void create_url_with_querystring_and_inputmodel() { var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.AddQueryInput(x => x.InQueryString); url.CreateUrl(new SampleViewModel { InPath = "5", InQueryString = "query" }).ShouldEqual("/test/edit/5?InQueryString=query"); }
public void create_url_with_null_input_model_and_no_default_value_specified_for_required_input() { var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{RequiredInput}"); url.AddRouteInput(x => x.RequiredInput); typeof (FubuException).ShouldBeThrownBy(() => url.CreateUrl(null)); }
public void create_url_with_null_input_model_and_no_default_value_specified_for_optional_input() { var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{OptionalInput}"); url.AddRouteInput(x => x.OptionalInput); url .CreateUrl(null) .ShouldEndWith("/test/edit/default"); }
public void create_url_with_multiple_variables_in_path() { var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}/{AlsoInPath}"); url.AddRouteInput(x => x.InPath); url.AddRouteInput(x => x.AlsoInPath); url.CreateUrl(new SampleViewModel { InPath = "5", AlsoInPath = "some text" }).ShouldEqual("/test/edit/5/some%20text"); }
public void create_url_with_multiple_variables_in_querystring() { var url = new RouteDefinition<SampleViewModel>("/my/sample/path"); var props = new List<Expression<Func<SampleViewModel, object>>> { x => x.InQueryString, x => x.AlsoInQueryString }; var inputs = props.Select(x => new RouteInput(ReflectionHelper.GetAccessor(x))); url.AddQueryInputs(inputs); url.CreateUrl(new SampleViewModel { InQueryString = "query", AlsoInQueryString = "alsoquery" }) .ShouldEqual("/my/sample/path?InQueryString=query&AlsoInQueryString=alsoquery"); }