示例#1
0
        public void CanAddHeaders()
        {
            var headers = new HttpHeadersAbstraction();

            headers.Add("Test", "Value");
            Assert.IsTrue(headers.Contains("Test"));
            Assert.AreEqual("Value", headers["Test"].First());
        }
示例#2
0
        public void CanClearHeaders()
        {
            var headers = new HttpHeadersAbstraction();

            headers.Add("Test", "Value");
            Assert.IsTrue(headers.Contains("Test"));

            headers.Clear();
            Assert.AreEqual(0, headers.Count());
        }
示例#3
0
        public static IHttpResponseAbstraction CreateResponse(HttpStatusCode code, IEnumerable <KeyValuePair <string, string> > headers, Stream content)
        {
            var abstractionHeaders = new HttpHeadersAbstraction();

            foreach (var header in headers)
            {
                abstractionHeaders.Add(header.Key, header.Value);
            }
            return(new HttpResponseAbstraction(content, abstractionHeaders, code));
        }
示例#4
0
        public void CanGetValuesHeaders()
        {
            var headers = new HttpHeadersAbstraction();
            var values  = new List <string>()
            {
                "value1", "value2"
            };

            headers.Add("Test", values);
            Assert.IsTrue(headers.Contains("Test"));
            Assert.AreEqual(values, headers.GetValues("Test"));
        }
示例#5
0
        public void CanTryGetValuesHeaders()
        {
            var headers = new HttpHeadersAbstraction();
            var values  = new List <string>()
            {
                "value1", "value2"
            };

            headers.Add("Test", values);

            IEnumerable <string> resValues = new List <string>();

            Assert.IsTrue(headers.TryGetValue("Test", out resValues));

            Assert.AreEqual(2, resValues.Count());
            Assert.AreEqual(values, resValues);
        }