private void CheckInvalidParse(string input) { Assert.Throws <FormatException>(() => { ViaHeaderValue.Parse(input); }); Assert.False(ViaHeaderValue.TryParse(input, out ViaHeaderValue result)); Assert.Null(result); }
public void Parse_Invalid() { try { ViaHeaderValue.Parse(null); Assert.Fail("#1"); } catch (FormatException) { } try { ViaHeaderValue.Parse(" "); Assert.Fail("#2"); } catch (FormatException) { } try { ViaHeaderValue.Parse("a"); Assert.Fail("#3"); } catch (FormatException) { } try { ViaHeaderValue.Parse("1 nowhere.com :43"); Assert.Fail("#4"); } catch (FormatException) { } }
public void Parse() { var res = ViaHeaderValue.Parse("1.1 nowhere.com"); Assert.IsNull(res.ProtocolName, "#1"); Assert.AreEqual("nowhere.com", res.ReceivedBy, "#2"); Assert.AreEqual("1.1", res.ProtocolVersion, "#3"); }
private void CheckValidParse(string input, ViaHeaderValue expectedResult) { ViaHeaderValue result = ViaHeaderValue.Parse(input); Assert.Equal(expectedResult, result); Assert.True(ViaHeaderValue.TryParse(input, out result)); Assert.Equal(expectedResult, result); }
public void Parse() { var res = ViaHeaderValue.Parse("1.1 nowhere.com"); Assert.IsNull(res.ProtocolName, "#1"); Assert.AreEqual("nowhere.com", res.ReceivedBy, "#2"); Assert.AreEqual("1.1", res.ProtocolVersion, "#3"); Assert.AreEqual("1.1 nowhere.com", res.ToString(), "#4"); res = ViaHeaderValue.Parse("foo / 1.1 nowhere.com:43 ( lalala ) "); Assert.AreEqual("foo", res.ProtocolName, "#10"); Assert.AreEqual("1.1", res.ProtocolVersion, "#11"); Assert.AreEqual("nowhere.com:43", res.ReceivedBy, "#12"); Assert.AreEqual("( lalala )", res.Comment, "#13"); Assert.AreEqual("foo/1.1 nowhere.com:43 ( lalala )", res.ToString(), "#14"); }
private void CheckInvalidParse(string input) { Assert.Throws <FormatException>(() => { ViaHeaderValue.Parse(input); }); }