public void BuildUrlGeneratesPathPartsAndQueryString()
        {
            // Arrange
            var page = "home";

            // Act
            var actual = UrlUtil.BuildUrl(page, "products", new { cat = 37 }, "furniture", new { sort = "name", dir = "desc" });

            // Assert
            Assert.Equal(actual, page + "/products/furniture?cat=37&sort=name&dir=desc");
        }
        public void BuildUrlEncodesPagePart()
        {
            // Arrange
            var page     = "This is a really bad name for a page";
            var expected = "This%20is%20a%20really%20bad%20name%20for%20a%20page";

            // Act
            var actual = UrlUtil.BuildUrl(page);

            // Assert
            Assert.Equal(actual, expected);
        }
        public void BuildUrlEncodesQueryStringKeysAndValues()
        {
            // Arrange
            var page        = "home";
            var queryString = new { ζ = "my=value&", mykey = "<π" };

            // Act
            var actual = UrlUtil.BuildUrl(page, queryString);

            // Assert
            Assert.Equal(actual, page + "?%ce%b6=my%3dvalue%26&mykey=%3c%cf%80");
        }
        public void BuildUrlAppendsAnonymousObjectsToQueryString()
        {
            // Arrange
            var page        = "home";
            var queryString = new { sort = "FName", dir = "desc" };

            // Act
            var actual = UrlUtil.BuildUrl(page, queryString);

            // Assert
            Assert.Equal(actual, page + "?sort=FName&dir=desc");
        }
        public void BuildUrlEncodesAppendedPathPortion()
        {
            // Arrange
            object[] pathParts = new object[] { "path portion", "ζ" };
            var      page      = "home";

            // Act
            var actual = UrlUtil.BuildUrl(page, pathParts);

            // Assert
            Assert.Equal(actual, page + "/path%20portion/%ce%b6");
        }
        public void BuildUrlAppendsNonAnonymousTypesToPathPortion()
        {
            // Arrange
            object[] pathParts = new object[] { "part", Decimal.One, 1.25f };
            var      page      = "home";

            // Act
            var actual = UrlUtil.BuildUrl(page, pathParts);

            // Assert
            Assert.Equal(actual, page + "/part/1/1.25");
        }
Ejemplo n.º 7
0
        public void BuildUrlEncodesPagePart()
        {
            // Arrange
            var page     = "This is a really bad name for a page";
            var expected = "This%20is%20a%20really%20bad%20name%20for%20a%20page";

            // Act
            string query;
            var    path = UrlUtil.BuildUrl(page, out query);

            // Assert
            Assert.Equal(path + query, expected);
        }
        public void BuildUrlAppendsMultipleAnonymousObjectsToQueryString()
        {
            // Arrange
            var page         = "home";
            var queryString1 = new { sort = "FName", dir = "desc" };
            var queryString2 = new { view = "Activities", page = 7 };

            // Act
            var actual = UrlUtil.BuildUrl(page, queryString1, queryString2);

            // Assert
            Assert.Equal(actual, page + "?sort=FName&dir=desc&view=Activities&page=7");
        }