Ejemplo n.º 1
0
        public void HttpHeaderCollection_Get()
        {
            HttpHeaderCollection headers;
            DateTime             date1 = new DateTime(2005, 11, 5, 11, 54, 15);
            DateTime             date2 = new DateTime(2005, 11, 6, 11, 54, 15);

            headers = new HttpHeaderCollection("GET", "/foo.htm");
            headers.Add("String", "Hello World!");
            headers.Add("Int", "10");
            headers.Add("Date", "Sat, 05 Nov 2005 11:54:15 GMT");

            Assert.AreEqual("Hello World!", headers.Get("string", null));
            Assert.AreEqual("Hello World!", headers.Get("STRING", null));
            Assert.AreEqual("foobar", headers.Get("Foobar", "foobar"));
            Assert.IsNull(headers.Get("Foobar", null));

            Assert.AreEqual(10, headers.Get("int", 0));
            Assert.AreEqual(10, headers.Get("INT", 0));
            Assert.AreEqual(77, headers.Get("Foo", 77));
            Assert.AreEqual(88, headers.Get("String", 88));

            Assert.AreEqual(date1, headers.Get("date", DateTime.MinValue));
            Assert.AreEqual(date1, headers.Get("DATE", DateTime.MinValue));
            Assert.AreEqual(date2, headers.Get("foo", date2));
            Assert.AreEqual(date2, headers.Get("string", date2));
        }