public void create_url_with_querystring_and_inputmodel_with_parameters()
        {
            var url = new RouteDefinition<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 void create_url_with_variables_in_querystring_with_parameters()
        {
            var url = new RouteDefinition<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 create_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] = "5";

            url.CreateUrlFromParameters(parameters).ShouldEqual("test/edit/5");
        }
        public void create_url_with_null_input_model_and_no_default_value_specified_for_required_input_with_parameters()
        {
            var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{RequiredInput}");
            url.AddRouteInput(x => x.RequiredInput);

            typeof(FubuException).ShouldBeThrownBy(() => url.CreateUrlFromParameters(null));
        }
        public void create_url_with_null_input_model_and_no_default_value_specified_for_optional_input_with_parameters()
        {
            var url = new RouteDefinition<SampleViewModelWithInputs>("test/edit/{OptionalInput}");
            url.AddRouteInput(x => x.OptionalInput);

            var parameters = new RouteParameters<SampleViewModelWithInputs>();

            url
                .CreateUrlFromParameters(parameters)
                .ShouldEndWith("test/edit/default");
        }
        public void create_url_with_multiple_variables_in_path_by_parameters()
        {
            var url = new RouteDefinition<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_input_model_and_default_value_for_required_input_by_parameters()
        {
            var url = new RouteDefinition<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");
        }