public static void ReadXmlToken_Returns_Correct_XmlToken(string xml, int expectedTokenSize, XmlTokenType tokenType, string expectedXml = null) { var xmlBytes = Encoding.UTF8.GetBytes(xml); var expectedTokenBytes = xmlBytes; if (expectedXml != null) { expectedTokenBytes = Encoding.UTF8.GetBytes(expectedXml); } var buffer = new ReadOnlySequence <byte>(xmlBytes); var expectedToken = new XmlToken(new ReadOnlySequence <byte>(expectedTokenBytes), tokenType); (int actualTokenSize, var actualToken) = XmlTokenDeserializer.Deserialize(buffer); Assert.Equal(expectedTokenSize, actualTokenSize); Assert.Equal(expectedToken.Type, actualToken.Type); Assert.Equal(expectedToken.BufferSegments.ToArray(), actualToken.BufferSegments.ToArray()); }
private static string GetXmlString(XmlToken token) => Encoding.UTF8.GetString(token.BufferSegments.ToArray());
public bool Equals(XmlToken token) { return(Type.Equals(token.Type) && BufferSegments.Equals(token.BufferSegments)); }