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¶m2=value2", queryString); }
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&")}¶m2={HttpUtility.UrlEncode("value2&")}"; Assert.AreEqual(compareUrl, queryString); }