本文整理汇总了C#中WebHeaderCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.Remove方法的具体用法?C# WebHeaderCollection.Remove怎么用?C# WebHeaderCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.Remove方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpRequestHeader_Add_Remove_Success
public void HttpRequestHeader_Add_Remove_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add(HttpRequestHeader.Warning, "Warning1");
Assert.Equal(1, w.Count);
Assert.Equal("Warning1", w[HttpRequestHeader.Warning]);
Assert.Equal("Warning", w.AllKeys[0]);
w.Remove(HttpRequestHeader.Warning);
Assert.Equal(0, w.Count);
}
示例2: Custom_AddThenRemove_Success
public void Custom_AddThenRemove_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Add("name", "value");
w.Remove("name");
Assert.Equal(0, w.Count);
}
示例3: Custom_RemoveIllegalCharacter_Throws
public void Custom_RemoveIllegalCharacter_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>(() => w.Remove("{"));
}
示例4: Custom_RemoveBlankName_Throws
public void Custom_RemoveBlankName_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>(() => w.Remove(""));
}
示例5: Remove_SetTwoThenRemoveOne_Success
public void Remove_SetTwoThenRemoveOne_Success(string setName, string removeName)
{
WebHeaderCollection w = new WebHeaderCollection();
w[setName] = "value";
w["foo"] = "bar";
w.Remove(removeName);
Assert.Equal(1, w.Count);
Assert.NotEmpty(w);
Assert.NotEmpty(w.AllKeys);
Assert.Equal(new[] { "foo" }, w.AllKeys);
Assert.Equal("bar", w["foo"]);
}
示例6: Remove_SetThenRemove_Success
public void Remove_SetThenRemove_Success(string setName, string removeName)
{
WebHeaderCollection w = new WebHeaderCollection();
w[setName] = "value";
w.Remove(removeName);
Assert.Equal(0, w.Count);
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
示例7: Remove_EmptyCollection_Success
public void Remove_EmptyCollection_Success()
{
WebHeaderCollection w = new WebHeaderCollection();
w.Remove("foo");
Assert.Equal(0, w.Count);
Assert.Empty(w);
Assert.Empty(w.AllKeys);
}
示例8: Remove_IllegalCharacter_Throws
public void Remove_IllegalCharacter_Throws()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentException>("name", () => w.Remove("{"));
}
示例9: Remove_NullOrEmptyName_Throws
public void Remove_NullOrEmptyName_Throws(string name)
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>("name", () => w.Remove(name));
}
示例10: HttpRequestHeader_Remove_Failure
public void HttpRequestHeader_Remove_Failure()
{
WebHeaderCollection w = new WebHeaderCollection();
Assert.Throws<ArgumentNullException>(() => w.Remove(null));
}
示例11: TestWebHeaderCollectionRemove
public void TestWebHeaderCollectionRemove()
{
WebHeaderCollection whc = new WebHeaderCollection();
whc.Add("some:stuff");
whc.Remove("some");
try
{
whc.Remove(null);
Fail("Remove: failed to throw exception for null argument");
}
catch (ArgumentNullException)
{
// Ok
}
try
{
whc.Remove("[NotValidHeader?]");
Fail("Remove: failed to throw exception for invalid header name: '[NotValidHeader?]'");
}
catch (ArgumentException)
{
// Yep...
}
try
{
whc.Remove("accept");
Fail("Remove: failed to throw exception for restricted header 'accept'");
}
catch (ArgumentException)
{
// Still moving along...
}
}