public void Parse_NullValue_Throw() { MediaTypeHeaderParser parser = MediaTypeHeaderParser.SingleValueParser; int index = 0; Assert.Throws <FormatException>(() => { parser.ParseValue(null, null, ref index); }); }
public void Parse_InvalidValue_Throw() { // This test verifies that Parse() correctly calls TryParse(). MediaTypeHeaderParser parser = MediaTypeHeaderParser.SingleValueParser; int index = 0; // only one value allowed. Assert.Throws <FormatException>(() => { parser.ParseValue("text/plain; charset=utf-8, next/mediatype", null, ref index); }); }
public void Parse_ValidValue_ReturnsMediaTypeHeaderValue() { // This test verifies that Parse() correctly calls TryParse(). MediaTypeHeaderParser parser = MediaTypeHeaderParser.SingleValueParser; int index = 2; MediaTypeHeaderValue expected = new MediaTypeHeaderValue("text/plain"); expected.CharSet = "utf-8"; Assert.True(expected.Equals(parser.ParseValue(" text / plain ; charset = utf-8 ", null, ref index))); Assert.Equal(34, index); }