Beispiel #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);
        }
Beispiel #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());
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
        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);
        }
        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);
        }
Beispiel #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));
 }
Beispiel #12
0
 public FilterQuery EqualTo(string value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.EqualTo, Quote(value)), Key, IdTokenFactory));
 }
Beispiel #13
0
 public FilterQuery EndAt(int value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.EndAt, value), Key, IdTokenFactory));
 }
Beispiel #14
0
 public FilterQuery StartAt(string value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.StartAt, Quote(value)), Key, IdTokenFactory));
 }
Beispiel #15
0
 public FilterQuery LimitToLast(int value)
 {
     return(new FilterQuery(UrlBuilder.AddParam(Params.LimitToLast, value), Key, IdTokenFactory));
 }