Ejemplo n.º 1
0
        public void ContainsKey()
        {
            var headers = new NameValueCollection()
            {
                { "Header#1", "Value #1-A" },
                { "Header#2", "Value #2" },
                { "Header#1", "Value #1-B" },
            };

            var response = new Mock <HttpResponseBase>(MockBehavior.Strict);

            response.SetupGet(r => r.Headers)
            .Returns(headers);

            var responseFeature = new HttpResponseHeaderDictionary(response.Object);

            responseFeature.ContainsKey("Header#1").Should().BeTrue();
            responseFeature.ContainsKey("Header#2").Should().BeTrue();
            responseFeature.ContainsKey("Header#NotExists").Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void ContentLength_WithNullValue()
        {
            var headers = new NameValueCollection()
            {
                { "Header#1", "Value #1-A" },
                { "Header#2", "Value #2" },
                { "Content-Length", "1234" },
            };

            var response = new Mock <HttpResponseBase>(MockBehavior.Strict);

            response.SetupGet(r => r.Headers)
            .Returns(headers);

            var responseFeature = new HttpResponseHeaderDictionary(response.Object);

            // Changes the content length to null
            responseFeature.ContentLength = null;

            responseFeature.ContentLength.Should().BeNull();
            responseFeature.ContainsKey("Content-Length").Should().BeFalse();
            headers.AllKeys.Contains("Content-Length").Should().BeFalse();
        }