示例#1
0
        public void Test_ToQueryString()
        {
            var queryParams = new Dictionary <string, string>()
            {
                { "param1", "value1" },
                { "param2", "value2" }
            };

            var queryString = UrlExtensions.ToQuerystring(queryParams);

            Assert.IsNotNull(queryString);
            Assert.AreEqual("?param1=value1&param2=value2", queryString);
        }
示例#2
0
        public void Test_ToQueryString_With_UrlEscaping()
        {
            var queryParams = new Dictionary <string, string>()
            {
                { "param1", "value1&" },
                { "param2", "value2&" }
            };

            var queryString = UrlExtensions.ToQuerystring(queryParams);

            Assert.IsNotNull(queryString);
            var compareUrl = $"?param1={HttpUtility.UrlEncode("value1&")}&param2={HttpUtility.UrlEncode("value2&")}";

            Assert.AreEqual(compareUrl, queryString);
        }