コード例 #1
0
        public void TestAddAndGetAndSet(HeaderType headerType)
        {
            string value1 = Guid.NewGuid().ToString();
            string value2 = Guid.NewGuid().ToString();
            INameValueCollection headers = this.CreateHeaders(headerType);

            headers.Add(Key, value1);

            Assert.AreEqual(value1, headers.Get(Key));
            headers.Set(Key, value2);
            Assert.AreEqual(value2, headers.Get(Key));
        }
コード例 #2
0
        public void VerifyUnKnownHeader(HeaderType headerType)
        {
            INameValueCollection headers = this.CreateHeaders(headerType);
            string key   = Guid.NewGuid().ToString();
            string value = Guid.NewGuid().ToString();

            headers[key] = value;
            Assert.AreEqual(value, headers[key]);
            Assert.AreEqual(value, headers[key.ToLower()]);
            Assert.AreEqual(value, headers[key.ToUpper()]);
            Assert.AreEqual(value, headers.Get(key));
            Assert.AreEqual(value, headers.Get(key.ToLower()));
            Assert.AreEqual(value, headers.Get(key.ToUpper()));
            Assert.AreEqual(key, headers.Keys().First());

            headers.Remove(key);
            Assert.IsNull(headers[key]);
        }
コード例 #3
0
        public static Dictionary <string, string> ToDictionary(INameValueCollection nvc)
        {
            var map = new Dictionary <string, string>();

            for (var i = 0; i < nvc.Count; i++)
            {
                map[nvc.GetKey(i)] = nvc.Get(i);
            }
            return(map);
        }
コード例 #4
0
 public static Dictionary<string, string> ToDictionary(INameValueCollection nvc)
 {
     var map = new Dictionary<string, string>();
     for (var i = 0; i < nvc.Count; i++)
     {
         map[nvc.GetKey(i)] = nvc.Get(i);
     }
     return map;
 }