示例#1
0
        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);
        }
示例#2
0
        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());
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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());
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
 /// <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));
 }
示例#12
0
 public FilterQuery EqualTo(string value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.EqualTo, Quote(value)), Key, IdTokenFactory));
 }
示例#13
0
 public FilterQuery EndAt(int value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.EndAt, value), Key, IdTokenFactory));
 }
示例#14
0
 public FilterQuery StartAt(string value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.StartAt, Quote(value)), Key, IdTokenFactory));
 }
示例#15
0
 public FilterQuery LimitToLast(int value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.LimitToLast, value), Key, IdTokenFactory));
 }