public void UriBuilderExtensionsTest_AddQueryParameters_ExistingQuery_ValidateQueryParams() { var uriBuidler = new UriBuilder(); uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2"; uriBuidler.AddQueryParams( new RequestParameter("Name3", "Value3"), new RequestParameter("Name4", "Value4"), new RequestParameter("Name5", "Value5"), new RequestParameter("Name6", "Value6") ); var qp = uriBuidler.GetQueryParams(); Assert.AreEqual("Name", qp[0].Name); Assert.AreEqual("Value", qp[0].Value); Assert.AreEqual("Name1", qp[1].Name); Assert.AreEqual("Value1", qp[1].Value); Assert.AreEqual("Name2", qp[2].Name); Assert.AreEqual("Value2", qp[2].Value); Assert.AreEqual("Name3", qp[3].Name); Assert.AreEqual("Value3", qp[3].Value); Assert.AreEqual("Name4", qp[4].Name); Assert.AreEqual("Value4", qp[4].Value); Assert.AreEqual("Name5", qp[5].Name); Assert.AreEqual("Value5", qp[5].Value); Assert.AreEqual("Name6", qp[6].Name); Assert.AreEqual("Value6", qp[6].Value); }
public void UriBuilderExtensionsTest_AddQueryParameters_ExistingEmptyQuery_ValidateQueryString() { var uriBuidler = new UriBuilder(); uriBuidler.AddQueryParams( new RequestParameter("Name3", "Value3"), new RequestParameter("Name4", "Value4"), new RequestParameter("Name5", "Value5"), new RequestParameter("Name6", "Value6") ); var qp = uriBuidler.GetQueryParams(); Assert.AreEqual("?Name3=Value3&Name4=Value4&Name5=Value5&Name6=Value6", uriBuidler.Query, "Query string does not match.!"); }
public void UriBuilderExtensionsTest_ClearQueryParameters_ValidateQueryString_ValidateQueryParams() { var uriBuidler = new UriBuilder(); uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2"; uriBuidler.AddQueryParams( new RequestParameter("Name3", "Value3"), new RequestParameter("Name4", "Value4"), new RequestParameter("Name5", "Value5"), new RequestParameter("Name6", "Value6") ); uriBuidler.ClearQueryParams(); var qp = uriBuidler.GetQueryParams(); Assert.IsTrue(uriBuidler.Query.Length == 0); }