Esempio n. 1
0
        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());
        }
Esempio n. 2
0
 private static string GetXmlString(XmlToken token) => Encoding.UTF8.GetString(token.BufferSegments.ToArray());
Esempio n. 3
0
 public bool Equals(XmlToken token)
 {
     return(Type.Equals(token.Type) &&
            BufferSegments.Equals(token.BufferSegments));
 }