public void TryParseAdd_AddValues_AllAdded()
        {
            MockHeaders headers = new MockHeaders();
            HttpHeaderValueCollection <Uri> collection = new HttpHeaderValueCollection <Uri>(knownUriHeader, headers);

            Assert.True(collection.TryParseAdd("http://www.example.org/1/"));
            Assert.True(collection.TryParseAdd("http://www.example.org/2/"));
            Assert.True(collection.TryParseAdd("http://www.example.org/3/"));

            Assert.Equal(3, collection.Count);
        }
        public void TryParseAdd_UseSpecialValue_Added()
        {
            MockHeaders headers = new MockHeaders();
            HttpHeaderValueCollection <Uri> collection = new HttpHeaderValueCollection <Uri>(knownUriHeader, headers,
                                                                                             specialValue);

            Assert.True(collection.TryParseAdd(specialValue.AbsoluteUri));

            Assert.True(collection.IsSpecialValueSet);
            Assert.Equal(specialValue.ToString(), collection.ToString());
        }
        public void TryParseAdd_UseSpecialValue_Added()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers,
                specialValue);

            Assert.True(collection.TryParseAdd(specialValue.AbsoluteUri));

            Assert.True(collection.IsSpecialValueSet);
            Assert.Equal(specialValue.ToString(), collection.ToString());
        }
        public void TryParseAdd_AddValues_AllAdded()
        {
            MockHeaders headers = new MockHeaders(knownHeader, new MockHeaderParser(typeof(Uri)));
            HttpHeaderValueCollection<Uri> collection = new HttpHeaderValueCollection<Uri>(knownHeader, headers,
                specialValue);

            Assert.True(collection.TryParseAdd("http://www.example.org/1/"));
            Assert.True(collection.TryParseAdd("http://www.example.org/2/"));
            Assert.True(collection.TryParseAdd("http://www.example.org/3/"));

            Assert.Equal(3, collection.Count);
        }
Esempio n. 5
0
 /// <summary>
 /// 配置Accept请求头
 /// </summary>
 /// <param name="accept">Accept请求头</param>
 protected override void ConfigureAccept(HttpHeaderValueCollection <MediaTypeWithQualityHeaderValue> accept)
 {
     accept.TryParseAdd(this.Accept);
 }