A custom dictionary that contains the headers in the context of an HTTP request or HTTP response.
Наследование: 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);
 }