A custom dictionary that contains the headers in the context of an HTTP request or HTTP response.
Inheritance: IHttpHeaders
示例#1
0
 public void Clear_WithPopulatedList_RemoveAllItems()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     headers.Clear();
     Assert.AreEqual(0, headers.Count);
 }
示例#2
0
        public void HeaderNames_WithPopulatedItems_ReturnsCollection()
        {
            var headers = new HttpHeaders();
            headers["abc"] = "123";

            var headerNames = headers.HeaderNames;
            Assert.AreEqual(1, headerNames.Count);
        }
示例#3
0
        public void CopyTo_WithValidHeaders_CopiesAllHeaders()
        {
            var source = new HttpHeaders();
            var target = new HttpHeaders();

            source["abc"] = "123";
            source["def"] = "456";

            source.CopyTo(target);

            Assert.AreEqual(source.Count, target.Count);
        }
示例#4
0
        public void CopyTo_WithValidHeaders_UpdatesExistingHeaders()
        {
            var source = new HttpHeaders();
            var target = new HttpHeaders();

            source["abc"] = "123";
            source["def"] = "456";
            target["abc"] = "999";

            source.CopyTo(target);

            Assert.AreEqual(source.Count, target.Count);
            Assert.AreEqual(source["abc"], target["abc"]);
        }
示例#5
0
 public void IndexerGet_WithValidHeaderNameDifferentCase_ReturnsValue()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.AreEqual("123", headers["ABC"]);
 }
示例#6
0
 public void IndexerGet_WithInvalidHeaderName_ReturnsNull()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.IsNull(headers["NoHeader"]);
 }
示例#7
0
 public void Count_WhenItemsAdded_ReturnsRealNumber()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.AreEqual(1, headers.Count);
 }
示例#8
0
 public void Constructor_WithDefaults_HasNoHeaders()
 {
     var headers = new HttpHeaders();
     Assert.AreEqual(0, headers.Count);
 }
示例#9
0
 public void Remove_WithValidName_ReturnsTrue()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.IsTrue(headers.Remove("abc"));
 }
示例#10
0
 public void Remove_WithValidName_RemoveFromList()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     headers.Remove("abc");
     Assert.AreEqual(0, headers.Count);
 }
示例#11
0
 public void Remove_WithInvalidName_ReturnsFalse()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.IsFalse(headers.Remove("defg"));
 }
示例#12
0
 public void IsReadOnly_WithGet_ReturnsFalse()
 {
     var headers = new HttpHeaders();
     Assert.IsFalse(headers.IsReadOnly);
 }
示例#13
0
 public void IndexerSet_WithSameName_UpdatesValue()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     headers["abc"] = "456";
     Assert.AreEqual("456", headers["abc"]);
 }
示例#14
0
        public void IndexerSet_WithNullValue_DoesNothing()
        {
            var headers = new HttpHeaders();

            Assert.DoesNotThrow(() => headers["abcd"] = null);

            Assert.AreEqual(0, headers.Count);
        }
示例#15
0
        public void IndexerSet_WithNullName_DoesNothing()
        {
            var headers = new HttpHeaders();

            Assert.DoesNotThrow(() => headers[null] = "1234");

            Assert.AreEqual(0, headers.Count);
        }
示例#16
0
 public void IndexerSet_WithNewValue_AddsToCollection()
 {
     var headers = new HttpHeaders();
     headers["abc"] = "123";
     Assert.AreEqual(1, headers.Count);
 }