public void is_satisfied_positive() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "something"; _parameter.IsSatisfied(parameters).ShouldBeTrue(); }
public void to_query_string_from_route_parameter_with_a_value() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "something"; _parameter.ToQueryString(parameters).ShouldEqual("Code=something"); }
public void resolve_a_url_with_route_params_explicitly_filled() { var values = new RouteParameters(); values["Name"] = "Joel"; theUrlResolver.UrlFor(theChainWithRouteParams, values).ShouldBe("/Joel"); }
public void is_satisfied_with_a_default_value_but_nothing_in_the_parameters() { var parameters = new RouteParameters<FakeInput>(); _parameter.DefaultValue = "something"; _parameter.IsSatisfied(parameters).ShouldBeTrue(); }
public void create_link_by_identifier() { theLinks.ToSubject(x => x.Id); var parameters = new RouteParameters<Site>(); parameters[x => x.Id] = theSubject.Id.ToString(); theLinks.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls) .Single().Url.ShouldEqual(theUrls.UrlFor(typeof(Site), parameters)); }
public void create_a_link_by_using_route_parameters() { theLinks.ToInput<SiteAction>(x => x.Name); var parameters = new RouteParameters<SiteAction>(); parameters["Name"] = theSubject.Name; theLinks.As<ILinkSource<Site>>().LinksFor(theTarget, theUrls) .Single().Url.ShouldEqual(theUrls.UrlFor(parameters)); }
public void the_route_has_route_input() { var input = theChain.Route.Input.ShouldBeOfType<RouteInput<MethodInput>>(); input.ShouldNotBeNull(); var parameters = new RouteParameters(); parameters["Start"] = "2"; parameters["End"] = "5"; input.CreateUrlFromParameters(parameters).ShouldEqual("cases/from/2/to/5"); }
public void should_constrain_routes_by_MethodToUrlBuilder_if_they_match() { var input = _policy.Build(HandlersObjectMother.HandlerWithRouteInput()).Input; var parameters = new RouteParameters(); parameters["Year"] = "2011"; parameters["Month"] = "7"; parameters["Title"] = "hello-world"; input .CreateUrlFromParameters(parameters) .ShouldEqual("posts/2011/7/hello-world"); }
public void create_url_with_multiple_variables_in_path_by_parameters() { var url = new RouteInput<SampleViewModel>("test/edit/{InPath}/{AlsoInPath}"); url.AddRouteInput(x => x.InPath); url.AddRouteInput(x => x.AlsoInPath); var parameters = new RouteParameters<SampleViewModel>(); parameters[x => x.InPath] = "5"; parameters[x => x.AlsoInPath] = "some text"; url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/5/some%20text"); }
public void create_url_with_null_input_model_and_no_default_value_specified_for_optional_input_with_parameters() { var url = new RouteInput<SampleViewModelWithInputs>("test/edit/{OptionalInput}"); url.AddRouteInput(x => x.OptionalInput); var parameters = new RouteParameters<SampleViewModelWithInputs>(); url .CreateUrlFromParameters(parameters) .ShouldEndWith("test/edit/default"); }
public void should_write_the_url_to_the_data_column() { var parameters = new RouteParameters(); parameters["Id"] = _id.ToString(); var url = theHarness.Urls.UrlFor(typeof(CaseActionModel), parameters); theDto["linkForAction"].ShouldEqual(url); }
public void create_url_with_input_model_and_default_value_for_required_input_by_parameters() { var url = new RouteInput<SampleViewModelWithInputs>("test/edit/{RequiredInput}"); url.AddRouteInput(x => x.RequiredInput); var parameters = new RouteParameters<SampleViewModelWithInputs>(); parameters[x => x.RequiredInput] = "a"; url .CreateUrlFromParameters(parameters) .ShouldEndWith("test/edit/a"); }
public void can_substitute_greedy_parameters_deals_with_html_encoding() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "laptop&apple"; _parameter.Substitute(parameters, "product/category/{*Code}").ShouldEqual("product/category/laptop%26apple"); }
public string ToQueryString(RouteParameters parameters) { return(makeQueryString(parameters[Name])); }
public void writes_the_url_to_the_first_column() { var parameters = new RouteParameters(); parameters["Id"] = _id.ToString(); var url = theHarness.Urls.UrlFor(typeof (Case), parameters); theDto["linkForCondition"].ShouldEqual(url); }
public void create_url_with_variables_in_querystring_with_parameters() { var url = new RouteInput<SampleViewModel>("/my/sample/path"); url.AddQueryInput(x => x.InQueryString); var parameters = new RouteParameters<SampleViewModel>(); parameters[x => x.InQueryString] = "query"; url.CreateUrlFromParameters(parameters).ShouldEqual("/my/sample/path?InQueryString=query"); }
public void substitute_on_route_parameter() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "something"; _parameter.Substitute(parameters, "aaa/{Code}/aaa").ShouldEqual("aaa/something/aaa"); }
public void substitute_on_route_parameter_deals_with_html_encoding() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "something&else"; _parameter.Substitute(parameters, "aaa/{Code}/aaa").ShouldEqual("aaa/something%26else/aaa"); }
public virtual string CreateUrlFromParameters(RouteParameters parameters) { throw new NotSupportedException(); }
public string UrlFor(BehaviorChain chain, RouteParameters parameters) { var url = chain.As<RoutedChain>().Route.Input.CreateUrlFromParameters(parameters); return _httpRequest.ToFullUrl(url); }
public void to_query_string_from_route_parameter_with_an_encoded_value() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "abc/def&ghi=jkl"; _parameter.ToQueryString(parameters).ShouldEqual("Code=abc%2Fdef%26ghi%3Djkl"); }
public void create_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] = "5"; url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/5"); }
public string Substitute(RouteParameters parameters, string url) { return substitute(url, parameters[_accessor.Name] ?? DefaultValue.ToString()); }
public void create_url_with_querystring_and_inputmodel_with_parameters() { var url = new RouteInput<SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); url.AddQueryInput(x => x.InQueryString); var parameters = new RouteParameters<SampleViewModel>(); parameters[x => x.InPath] = "5"; parameters[x => x.InQueryString] = "query"; url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/5?InQueryString=query"); }
public bool IsSatisfied(RouteParameters routeParameters) { return(routeParameters.Has(_accessor.Name) || DefaultValue != null); }
public bool IsSatisfied(RouteParameters routeParameters) { return routeParameters.Has(_accessor.Name) || DefaultValue != null; }
public void can_substitute_greedy_parameters() { var parameters = new RouteParameters<FakeInput>(); parameters[x => x.Code] = "computers/laptop/i7/dell&ibm"; _parameter.Substitute(parameters, "product/category/{*Code}").ShouldEqual("product/category/computers/laptop/i7/dell%26ibm"); }
public string ToQueryString(RouteParameters parameters) { return makeQueryString(parameters[Name]); }
public string Substitute(RouteParameters parameters, string url) { return(substitute(url, parameters[_accessor.Name] ?? DefaultValue.ToString())); }
public void create_url_with_encoded_variables_in_path_by_parameters() { var url = new RouteInput<SampleViewModel>("test/edit/{InPath}/{AlsoInPath}"); url.AddRouteInput(x => x.InPath); url.AddRouteInput(x => x.AlsoInPath); var parameters = new RouteParameters<SampleViewModel>(); parameters[x => x.InPath] = "5"; parameters[x => x.AlsoInPath] = "abc/def&ghi=jkl"; url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/5/abc%2Fdef%26ghi%3Djkl"); }
public void create_url_will_escape_the_url_with_parameters() { var url = new RouteDefinition<SampleViewModel>("test/edit/{InPath}"); url.AddRouteInput(x => x.InPath); var parameters = new RouteParameters<SampleViewModel>(); parameters[x => x.InPath] = "some text"; url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/some%20text"); }
public void retrieve_url_by_input_type_with_parameters() { var parameters = new RouteParameters<ModelWithInputs>(); parameters[x => x.Name] = "Max"; urls.UrlFor<ModelWithInputs>(parameters).ShouldEqual("/find/Max"); }
public void create_url_with_input_model_and_default_value_for_optional_input_with_parameters() { var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{OptionalInput}"); url.AddRouteInput(x => x.OptionalInput); var parameters = new RouteParameters<SampleViewModelWithInputs>(); parameters[x => x.OptionalInput] = "a"; url .CreateUrlFromParameters(parameters) .ShouldEndWith("test/edit/a"); }
public string CreateUrlFromParameters(RouteParameters parameters) { return(Pattern); }