Ejemplo n.º 1
0
        public void AddPathWithParamsEnsuresSlashAreNotRepeated()
        {
            // Arrange
            var pagePath = "~/dir/page/";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);

            builder.AddPath("foo", "/bar/", "/baz").AddPath("qux/");

            // Assert
            Assert.Equal("dir/page/foo/bar/baz/qux/", builder.Path);
        }
Ejemplo n.º 2
0
        public void AddPathEncodesPathParams()
        {
            // Arrange
            var pagePath = "~/dir/page?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);

            builder.AddPath("foo bar").AddPath("baz biz", "qux");

            // Assert
            Assert.Equal("dir/page/foo%20bar/baz%20biz/qux", builder.Path);
        }
Ejemplo n.º 3
0
        public void AddPathWithParamsArrayAddsPathPortionToAbsoluteUrl()
        {
            // Arrange
            var pagePath = "http://www.test.com/dir/page/?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);

            builder.AddPath("foo", "bar", "baz").AddPath("qux");

            // Assert
            Assert.Equal("http://www.test.com/dir/page/foo/bar/baz/qux", builder.Path);
            Assert.Equal("?someparam=value", builder.QueryString);
        }
Ejemplo n.º 4
0
        public void AddPathAddsPathPortionToAbsoluteUrl()
        {
            // Arrange
            var pagePath = "http://some-site/dir/page?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);

            builder.AddPath("foo").AddPath("bar/baz");

            // Assert
            Assert.Equal("http://some-site/dir/page/foo/bar/baz", builder.Path);
            Assert.Equal("?someparam=value", builder.QueryString);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns an object URL with the given selector.
        /// </summary>
        public UrlBuilder GetPathUrl(string repositoryId, string path)
        {
            String url = GetRootUrl(repositoryId);

            if (url == null)
            {
                return(null);
            }

            UrlBuilder result = new UrlBuilder(url);

            result.AddPath(path);

            return(result);
        }
Ejemplo n.º 6
0
        public void AddPathWithParamsArrayAddsPathPortionToAbsoluteUrl()
        {
            // Arrange
            var pagePath = "http://www.test.com/dir/page/?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);
            builder.AddPath("foo", "bar", "baz").AddPath("qux");

            // Assert
            Assert.Equal("http://www.test.com/dir/page/foo/bar/baz/qux", builder.Path);
            Assert.Equal("?someparam=value", builder.QueryString);
        }
Ejemplo n.º 7
0
        public void AddPathWithParamsEnsuresSlashAreNotRepeated()
        {
            // Arrange
            var pagePath = "~/dir/page/";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);
            builder.AddPath("foo", "/bar/", "/baz").AddPath("qux/");

            // Assert
            Assert.Equal("dir/page/foo/bar/baz/qux/", builder.Path);
        }
Ejemplo n.º 8
0
        public void AddPathAddsPathPortionToAbsoluteUrl()
        {
            // Arrange
            var pagePath = "http://some-site/dir/page?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);
            builder.AddPath("foo").AddPath("bar/baz");

            // Assert
            Assert.Equal("http://some-site/dir/page/foo/bar/baz", builder.Path);
            Assert.Equal("?someparam=value", builder.QueryString);
        }
Ejemplo n.º 9
0
        public void AddPathEncodesPathParams()
        {
            // Arrange
            var pagePath = "~/dir/page?someparam=value";

            // Act
            var builder = new UrlBuilder(GetContext(), _virtualPathUtility, pagePath, null);
            builder.AddPath("foo bar").AddPath("baz biz", "qux");

            // Assert
            Assert.Equal("dir/page/foo%20bar/baz%20biz/qux", builder.Path);
        }