本文整理汇总了C#中Response.WithHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# Response.WithHeaders方法的具体用法?C# Response.WithHeaders怎么用?C# Response.WithHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.WithHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_append_to_existing_headers_if_already_in_response
public void Should_append_to_existing_headers_if_already_in_response()
{
var response = new Response();
response.Headers = new Dictionary<string, string>();
response.Headers.Add("Existing", "Test");
var result = response.WithHeaders(new[] { Tuple.Create("test", "test") });
result.Headers.ShouldNotBeNull();
result.Headers.Count.ShouldEqual(2);
}
示例2: Should_be_able_to_supply_withHeaders_headers_as_anonymous_types
public void Should_be_able_to_supply_withHeaders_headers_as_anonymous_types()
{
var response = new Response();
var result = response.WithHeaders(
new { Header = "test", Value = "testvalue" },
new { Header = "test2", Value = "test2value" });
result.Headers.ShouldNotBeNull();
result.Headers["test"].ShouldEqual("testvalue");
result.Headers["test2"].ShouldEqual("test2value");
}
示例3: Should_add_all_headers_using_withheaders
public void Should_add_all_headers_using_withheaders()
{
var response = new Response();
var result = response.WithHeaders(
Tuple.Create("test", "testvalue"),
Tuple.Create("test2", "test2value"));
result.Headers.ShouldNotBeNull();
result.Headers["test"].ShouldEqual("testvalue");
result.Headers["test2"].ShouldEqual("test2value");
}
示例4: Should_handle_null_response_headers_using_withheaders
public void Should_handle_null_response_headers_using_withheaders()
{
var response = new Response();
response.Headers = null;
var result = response.WithHeaders(new[] { Tuple.Create("test", "test") });
result.Headers.ShouldNotBeNull();
result.Headers.Count.ShouldEqual(1);
}