Ejemplo n.º 1
0
        public void Should_ignore_accept_language_header_values_with_invalid_quality()
        {
            // Given
            var values = new[] { "en-US, sv-SE;q=a" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Accept-Language", values } };

            // When
            var headers = new RequestHeaders(rawHeaders).AcceptLanguage.ToList();

            // Then
            headers.ShouldHaveCount(2);
            headers.ShouldHave(t => t.Item1 == "en-US" && t.Item2 == 1.0m);
            headers.ShouldHave(t => t.Item1 == "sv-SE" && t.Item2 == 1.0m);
        }
Ejemplo n.º 2
0
        public void Should_not_strip_additional_accept_header_parameters()
        {
            // Given
            var values = new[] { "text/plain, text/ninja;q=0.3;a=1;b=2" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Accept", values } };

            // When
            var headers = new RequestHeaders(rawHeaders).Accept.ToList();

            // Then
            headers.ShouldHaveCount(2);
            headers.ShouldHave(t => t.Item1 == "text/plain" && t.Item2 == 1.0m);
            headers.ShouldHave(t => t.Item1 == "text/ninja;a=1;b=2" && t.Item2 == 0.3m);
         }
Ejemplo n.º 3
0
        public void Should_ignore_accept_charset_header_values_with_invalid_quality()
        {
            // Given
            var values = new[] { "utf-8, iso-8859-5;q=a" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Accept-Charset", values } };

            // When
            var headers = new RequestHeaders(rawHeaders).AcceptCharset.ToList();

            // Then
            headers.ShouldHaveCount(2);
            headers.ShouldHave(t => t.Item1 == "utf-8" && t.Item2 == 1.0m);
            headers.ShouldHave(t => t.Item1 == "iso-8859-5" && t.Item2 == 1.0m);
        }
Ejemplo n.º 4
0
        public void Should_ignore_accept_header_values_with_invalid_quality()
        {
            // Given
            var values = new[] { "text/plain, text/ninja;q=a" };
            var rawHeaders = new Dictionary<string, IEnumerable<string>> { { "Accept", values } };

            // When
            var headers = new RequestHeaders(rawHeaders).Accept.ToList();

            // Then
            headers.ShouldHaveCount(2);
            headers.ShouldHave(t => t.Item1 == "text/plain" && t.Item2 == 1.0m);
            headers.ShouldHave(t => t.Item1 == "text/ninja" && t.Item2 == 1.0m);
        }