public void ManipulateParameters() { UriBuilder b = new UriBuilder("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=b#v"); b.SetParam("a", "c"); Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=c#v", b.ToString()); b.AddParam("b", "x"); Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=c&b=x#v", b.ToString()); b.AddParam("b", "y"); Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html?a=c&b=x&b=y#v", b.ToString()); b.Query = null; Assert.AreEqual("http://*****:*****@www.neopoly.de:8080/the/path/index.html#v", b.ToString()); }
public void SimplyAddsParamToQuery() { UriBuilder b = new UriBuilder("http://test.host"); b.AddParam("p1", "1"); b.AddParam("p2", "2"); Assert.AreEqual("http://test.host/?p1=1&p2=2", b.ToString()); b.AddParams(new NameValueCollection { { "p3", "3" }, { "p3", string.Empty }, { "p4", null }, }); Assert.AreEqual("http://test.host/?p1=1&p2=2&p3=3&p3=&p4=", b.ToString()); }