Exemple #1
0
        public void TryParseStrictList_WithSomeInvalidValues_ReturnsFalse()
        {
            var inputs = new[]
            {
                "text/html,application/xhtml+xml, ignore-this, ignore/this",
                "application/xml;q=0.9,image/webp,*/*;q=0.8",
                "application/xml;q=0 4"
            };

            Assert.False(MediaTypeHeaderValue.TryParseStrictList(inputs, out var results));
        }
Exemple #2
0
        public void TryParseStrictList_SetOfValidValueStrings_ReturnsTrue()
        {
            var inputs = new[] { "text/html,application/xhtml+xml,", "application/xml;q=0.9,image/webp,*/*;q=0.8" };

            Assert.True(MediaTypeHeaderValue.TryParseStrictList(inputs, out var results));

            var expectedResults = new[]
            {
                new MediaTypeHeaderValue("text/html"),
                new MediaTypeHeaderValue("application/xhtml+xml"),
                new MediaTypeHeaderValue("application/xml", 0.9),
                new MediaTypeHeaderValue("image/webp"),
                new MediaTypeHeaderValue("*/*", 0.8),
            }.ToList();

            Assert.Equal(expectedResults, results);
        }