public void Parse_Invalid() { try { WarningHeaderValue.Parse(null); Assert.Fail("#1"); } catch (FormatException) { } try { WarningHeaderValue.Parse(" "); Assert.Fail("#2"); } catch (FormatException) { } try { WarningHeaderValue.Parse("a"); Assert.Fail("#3"); } catch (FormatException) { } try { WarningHeaderValue.Parse("5555 foo:8080 \"\""); Assert.Fail("#4"); } catch (FormatException) { } }
private void CheckInvalidParse(string input) { Assert.Throws <FormatException>(() => { WarningHeaderValue.Parse(input); }); Assert.False(WarningHeaderValue.TryParse(input, out WarningHeaderValue result)); Assert.Null(result); }
public void Parse() { var res = WarningHeaderValue.Parse("1 n \"\""); Assert.IsNull(res.Date, "#1"); Assert.AreEqual(1, res.Code, "#2"); Assert.AreEqual("n", res.Agent, "#3"); Assert.AreEqual("\"\"", res.Text, "#4"); }
private void CheckValidParse(string input, WarningHeaderValue expectedResult) { WarningHeaderValue result = WarningHeaderValue.Parse(input); Assert.Equal(expectedResult, result); Assert.True(WarningHeaderValue.TryParse(input, out result)); Assert.Equal(expectedResult, result); }
public void Parse() { var res = WarningHeaderValue.Parse("1 n \"\""); Assert.IsNull(res.Date, "#1"); Assert.AreEqual(1, res.Code, "#2"); Assert.AreEqual("n", res.Agent, "#3"); Assert.AreEqual("\"\"", res.Text, "#4"); Assert.AreEqual("001 n \"\"", res.ToString(), "#5"); res = WarningHeaderValue.Parse("155 foo:8080 \"tttext \" \"Sunday, 06-Nov-94 08:49:37 GMT\" "); Assert.AreEqual(new DateTimeOffset(1994, 11, 6, 8, 49, 37, TimeSpan.Zero), res.Date, "#11"); Assert.AreEqual(155, res.Code, "#12"); Assert.AreEqual("foo:8080", res.Agent, "#13"); Assert.AreEqual("\"tttext \"", res.Text, "#14"); Assert.AreEqual("155 foo:8080 \"tttext \" \"Sun, 06 Nov 1994 08:49:37 GMT\"", res.ToString(), "#5"); }
private void CheckInvalidParse(string input) { Assert.Throws <FormatException>(() => { WarningHeaderValue.Parse(input); }); }