Ejemplo n.º 1
0
        public void GetHeaderValueEmpty()
        {
            IHeaderDictionary headers = new HeaderDictionary();
            var values = HttpHeadersUtilities.SafeGetCommaSeparatedHeaderValues(headers, W3C.W3CConstants.TraceStateHeader, 100500, 100500)?.ToList();

            Assert.NotNull(values);
            Assert.Empty(values);
        }
Ejemplo n.º 2
0
        public void GetHeaderValueMaxItemsTruncatesEndInvalid()
        {
            IHeaderDictionary headers = new HeaderDictionary(new Dictionary <string, StringValues> {
                [W3C.W3CConstants.TraceStateHeader] = "k1=v1,k2=v2"
            });
            var values = HttpHeadersUtilities.SafeGetCommaSeparatedHeaderValues(headers, W3C.W3CConstants.TraceStateHeader, 100500, 0)?.ToList();

            Assert.NotNull(values);
            Assert.Empty(values);
        }
Ejemplo n.º 3
0
        public void GetHeaderValueMaxItemsTruncatesEnd()
        {
            IHeaderDictionary headers = new HeaderDictionary(new Dictionary <string, StringValues> {
                [W3C.W3CConstants.TraceStateHeader] = "k1=v1,k2=v2,k3=v3,k4=v4"
            });
            var values = HttpHeadersUtilities.SafeGetCommaSeparatedHeaderValues(headers, W3C.W3CConstants.TraceStateHeader, 100500, 2)?.ToList();

            Assert.NotNull(values);
            Assert.Equal(2, values.Count);
            Assert.Equal("k1=v1", values.First());
            Assert.Equal("k2=v2", values.Last());
        }
Ejemplo n.º 4
0
        public void GetHeaderValueNoMax2()
        {
            IHeaderDictionary headers = new HeaderDictionary(new Dictionary <string, StringValues> {
                [W3C.W3CConstants.TraceStateHeader] = new [] { "k1=v1,k2=v2", "k3=v3,k4=v4" }
            });
            var values = HttpHeadersUtilities.SafeGetCommaSeparatedHeaderValues(headers, W3C.W3CConstants.TraceStateHeader, 100500, 100500)?.ToList();

            Assert.NotNull(values);
            Assert.Equal(4, values.Count);
            Assert.Equal("k1=v1", values[0]);
            Assert.Equal("k2=v2", values[1]);
            Assert.Equal("k3=v3", values[2]);
            Assert.Equal("k4=v4", values[3]);
        }