Esempio n. 1
0
        public void Net_UrlBuilder_Querystring()
        {
            // Test manually building querystring uri
            string manualQuerystring = "http://localhost:80";

            manualQuerystring += String.Join("&", QuerystringList.ToString("QS"));
            manualQuerystring  = manualQuerystring.RemoveFirst("&");
            manualQuerystring  = manualQuerystring.AddFirst("?");
            Assert.IsTrue(manualQuerystring.Contains(LocalhostWithPortAsString));
            Assert.IsTrue(manualQuerystring.Contains("?key1=param1"));
            Assert.IsTrue(manualQuerystring.Contains("&key2=param2"));
            Assert.IsTrue(manualQuerystring.Contains("&key3=param3"));

            // Now test UrlBuilder
            var testItem = new UrlBuilder(LocalhostWithPortAsUri.ToString(), QuerystringList);

            Assert.IsTrue(testItem.ToString().Contains(LocalhostWithPortAsString));
            Assert.IsTrue(testItem.ToString().Contains("?key1=param1"));
            Assert.IsTrue(testItem.ToString().Contains("&key2=param2"));
            Assert.IsTrue(testItem.ToString().Contains("&key3=param3"));
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor that formats the entire URL, complete with PROTOCOL://SERVER_NAME:PORT/APPLICATION_PATH/Parameter1/Parameter2/.../ParameterN/
 /// </summary>
 /// <param name="urlNoQuerystring">Url with everything but parameters and punctuation</param>
 /// <param name="parameters">Collection of parameters to add to Url</param>
 /// <returns>Constructed url</returns>
 public UrlBuilder(string urlNoQuerystring, KeyValueListString parameters)
     : base(urlNoQuerystring.AddLast("/") + parameters.ToString("QS"))
 {
 }