本文整理汇总了C#中System.UriBuilder.AddQueryParams方法的典型用法代码示例。如果您正苦于以下问题:C# UriBuilder.AddQueryParams方法的具体用法?C# UriBuilder.AddQueryParams怎么用?C# UriBuilder.AddQueryParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UriBuilder
的用法示例。
在下文中一共展示了UriBuilder.AddQueryParams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UriBuilderExtensionsTest_AddQueryParameters_ExistingQuery_ValidateQueryParams
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);
}
示例2: UriBuilderExtensionsTest_AddQueryParameters_ExistingEmptyQuery_ValidateQueryString
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.!");
}
示例3: UriBuilderExtensionsTest_ClearQueryParameters_ValidateQueryString_ValidateQueryParams
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);
}
示例4: UriBuilderExtensionsTest_AddQueryParameters_InvalidInput_ThrowsException
public void UriBuilderExtensionsTest_AddQueryParameters_InvalidInput_ThrowsException()
{
var uriBuidler = new UriBuilder();
uriBuidler.Query = "Name=Value&Name1=Value1&Name2=Value2";
try
{
uriBuidler.AddQueryParams(null);
}
catch (ArgumentNullException) { return; }
Assert.Fail("Expecting ArgumentNullException!");
}