本文整理汇总了C#中System.Net.WebHeaderCollection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.ToString方法的具体用法?C# WebHeaderCollection.ToString怎么用?C# WebHeaderCollection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultPropertyValues_ReturnEmptyAfterConstruction_Success
public void DefaultPropertyValues_ReturnEmptyAfterConstruction_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Equal(0, w.AllKeys.Length);
Assert.Equal(0, w.Count);
Assert.Equal("\r\n", w.ToString());
}
示例2: ToStringTest
public void ToStringTest ()
{
col.Add ("Name1", "Value1b");
col.Add ("Name3", "Value3a\r\n Value3b");
col.Add ("Name4", " Value4 ");
Assert.AreEqual ("Name1: Value1,Value1b\r\nName2: Value2\r\nName3: Value3a\r\n Value3b\r\nName4: Value4\r\n\r\n", col.ToString (), "#1");
WebHeaderCollection w;
w = new WebHeaderCollection ();
w.Add (HttpResponseHeader.KeepAlive, "Value1");
w.Add (HttpResponseHeader.WwwAuthenticate, "Value2");
Assert.AreEqual ("Keep-Alive: Value1\r\nWWW-Authenticate: Value2\r\n\r\n", w.ToString (), "#2");
w = new WebHeaderCollection ();
w.Add (HttpRequestHeader.UserAgent, "Value1");
w.Add (HttpRequestHeader.ContentMd5, "Value2");
Assert.AreEqual ("User-Agent: Value1\r\nContent-MD5: Value2\r\n\r\n", w.ToString (), "#3");
}
示例3: ToString_Success
public void ToString_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("Accept", "text/plain");
w.Add("Content-Length", "123");
Assert.Equal(
"Accept: text/plain\r\nContent-Length: 123\r\n\r\n",
w.ToString());
}