コード例 #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());
        }
コード例 #2
0
 private static string GetXmlString(XmlToken token) => Encoding.UTF8.GetString(token.BufferSegments.ToArray());
コード例 #3
0
ファイル: XmlToken.cs プロジェクト: BuzzX8/HyperMsg.Xmpp
 public bool Equals(XmlToken token)
 {
     return(Type.Equals(token.Type) &&
            BufferSegments.Equals(token.BufferSegments));
 }