public void UrlBuilderEncodesParameters() { // Arrange var pagePath = "~/dir/page/?someparam=value"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, new { Λ = "λ" }); builder.AddParam(new { π = "is not a lie" }).AddParam("Π", "maybe a lie"); // Assert Assert.Equal("?someparam=value&%ce%9b=%ce%bb&%cf%80=is+not+a+lie&%ce%a0=maybe+a+lie", builder.QueryString); }
public void ToStringConcatsPathAndQueryString() { // Arrange var pagePath = "~/dir/page"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddParam("foo", "bar").AddParam(new { baz = "qux", biz = "quark" }); // Assert Assert.Equal("dir/page?foo=bar&baz=qux&biz=quark", builder.ToString()); }
public void AddParamIgnoresParametersWithEmptyKey() { // Arrange var pagePath = "~/dir/page"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddParam("", "bar").AddParam(new { baz = "", biz = "quark" }).AddParam("qux", null).AddParam(null, "somevalue"); // Assert Assert.Equal("?baz=&biz=quark&qux=", builder.QueryString); }
public void AddParamAddsQuestionMarkToQueryStringIfFirstParam() { // Arrange var pagePath = "~/dir/page"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddParam("foo", "bar").AddParam(new { baz = "qux", biz = "quark" }); // Assert Assert.Equal("?foo=bar&baz=qux&biz=quark", builder.QueryString); }
public void AddParamAddsParamToQueryString() { // Arrange var pagePath = "http://www.test.com/dir/page/?someparam=value"; // Act var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null); builder.AddParam("foo", "bar"); // Assert Assert.Equal("?someparam=value&foo=bar", builder.QueryString); }
/// <summary> /// Orders the data according to the specified property in order to filter it. /// </summary> /// <param name="property">The property used to sort. To access a nested property, use slashes (ex.: info/dimensions/height).</param> public FilterQuery OrderBy(string property) { return(new FilterQuery(UrlBuilder.AddParam(Params.OrderBy, Quote(property)), Key, IdTokenFactory)); }
public FilterQuery EqualTo(string value) { return(new FilterQuery(UrlBuilder.AddParam(Params.EqualTo, Quote(value)), Key, IdTokenFactory)); }
public FilterQuery EndAt(int value) { return(new FilterQuery(UrlBuilder.AddParam(Params.EndAt, value), Key, IdTokenFactory)); }
public FilterQuery StartAt(string value) { return(new FilterQuery(UrlBuilder.AddParam(Params.StartAt, Quote(value)), Key, IdTokenFactory)); }
public FilterQuery LimitToLast(int value) { return(new FilterQuery(UrlBuilder.AddParam(Params.LimitToLast, value), Key, IdTokenFactory)); }