public void TryParseList_NullOrEmptyArray_ReturnsFalse() { IList <MediaTypeHeaderValue> results; Assert.False(MediaTypeHeaderValue.TryParseList(null, out results)); Assert.False(MediaTypeHeaderValue.TryParseList(new string[0], out results)); Assert.False(MediaTypeHeaderValue.TryParseList(new string[] { "" }, out results)); }
public void TryParseList_WithSomeInvlaidValues_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" }; IList <MediaTypeHeaderValue> results; Assert.False(MediaTypeHeaderValue.TryParseList(inputs, out results)); }
public void TryParseList_SetOfValidValueStrings_ReturnsTrue() { var inputs = new[] { "text/html,application/xhtml+xml,", "application/xml;q=0.9,image/webp,*/*;q=0.8" }; Assert.True(MediaTypeHeaderValue.TryParseList(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); }
public void TryParseList_WithSomeInvalidValues_IgnoresInvalidValues() { 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.True(MediaTypeHeaderValue.TryParseList(inputs, out var results)); var expectedResults = new[] { new MediaTypeHeaderValue("text/html"), new MediaTypeHeaderValue("application/xhtml+xml"), new MediaTypeHeaderValue("ignore/this"), new MediaTypeHeaderValue("application/xml", 0.9), new MediaTypeHeaderValue("image/webp"), new MediaTypeHeaderValue("*/*", 0.8), }.ToList(); Assert.Equal(expectedResults, results); }