Exemplo n.º 1
0
        public void is_satisfied_positive()
        {
            var parameters = new RouteParameters<FakeInput>();
            parameters[x => x.Code] = "something";

            _parameter.IsSatisfied(parameters).ShouldBeTrue();
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 7
0
        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");
        }
Exemplo n.º 9
0
        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");
        }
Exemplo n.º 10
0
        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");
        }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
        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");
        }
Exemplo n.º 13
0
 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");
 }
Exemplo n.º 14
0
 public string ToQueryString(RouteParameters parameters)
 {
     return(makeQueryString(parameters[Name]));
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
        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");
        }
Exemplo n.º 17
0
 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");
 }
Exemplo n.º 18
0
 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");
 }
Exemplo n.º 19
0
 public virtual string CreateUrlFromParameters(RouteParameters parameters)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 20
0
        public string UrlFor(BehaviorChain chain, RouteParameters parameters)
        {
            var url = chain.As<RoutedChain>().Route.Input.CreateUrlFromParameters(parameters);

            return _httpRequest.ToFullUrl(url);
        }
Exemplo n.º 21
0
        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");
        }
Exemplo n.º 22
0
        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");
        }
Exemplo n.º 23
0
 public string Substitute(RouteParameters parameters, string url)
 {
     return substitute(url, parameters[_accessor.Name] ?? DefaultValue.ToString());
 }
Exemplo n.º 24
0
        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");
        }
Exemplo n.º 25
0
 public bool IsSatisfied(RouteParameters routeParameters)
 {
     return(routeParameters.Has(_accessor.Name) || DefaultValue != null);
 }
Exemplo n.º 26
0
 public bool IsSatisfied(RouteParameters routeParameters)
 {
     return routeParameters.Has(_accessor.Name) || DefaultValue != null;
 }
Exemplo n.º 27
0
 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");
 }
Exemplo n.º 28
0
 public string ToQueryString(RouteParameters parameters)
 {
     return makeQueryString(parameters[Name]);
 }
Exemplo n.º 29
0
 public virtual string CreateUrlFromParameters(RouteParameters parameters)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 30
0
 public string Substitute(RouteParameters parameters, string url)
 {
     return(substitute(url, parameters[_accessor.Name] ?? DefaultValue.ToString()));
 }
Exemplo n.º 31
0
        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");
        }
Exemplo n.º 32
0
        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");
        }
Exemplo n.º 33
0
        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");
        }
Exemplo n.º 34
0
        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");
        }
Exemplo n.º 35
0
 public string CreateUrlFromParameters(RouteParameters parameters)
 {
     return(Pattern);
 }