Encode() public method

public Encode ( byte buffer, int offset ) : int
buffer byte
offset int
return int
        public void HandshakeSupportsTest()
        {
            ExtendedHandshakeMessage m = new ExtendedHandshakeMessage();
            byte[] encoded = m.Encode();

            Assert.AreEqual(m.ByteLength, encoded.Length, "#1");
            Assert.IsTrue(m.Supports.Exists(delegate(ExtensionSupport s) { return s.Name.Equals(PeerExchangeMessage.Support.Name); }), "#2");
            Assert.IsTrue(m.Supports.Exists(delegate(ExtensionSupport s) { return s.Name.Equals(LTChat.Support.Name); }), "#3");
            Assert.IsTrue(m.Supports.Exists(delegate(ExtensionSupport s) { return s.Name.Equals(LTMetadata.Support.Name); }), "#4");
        }
        public void HandshakeSupportsTest()
        {
            var message = new ExtendedHandshakeMessage();
            var encoded = message.Encode();

            Assert.AreEqual(message.ByteLength, encoded.Length, "#1");
            Assert.IsTrue(message.Supports.Exists(s => s.Name.Equals(PeerExchangeMessage.Support.Name)), "#2");
            Assert.IsTrue(message.Supports.Exists(s => s.Name.Equals(LTChat.Support.Name)), "#3");
            Assert.IsTrue(message.Supports.Exists(s => s.Name.Equals(LTMetadata.Support.Name)), "#4");
        }
        public void HandshakeDecodeTest()
        {
            ExtendedHandshakeMessage m = new ExtendedHandshakeMessage();
            byte[] data = m.Encode();
            ExtendedHandshakeMessage decoded = (ExtendedHandshakeMessage)PeerMessage.DecodeMessage(data, 0, data.Length, rig.Manager);

            Assert.AreEqual(m.ByteLength, data.Length);
            Assert.AreEqual(m.ByteLength, decoded.ByteLength, "#1");
            Assert.AreEqual(m.LocalPort, decoded.LocalPort, "#2");
            Assert.AreEqual(m.MaxRequests, decoded.MaxRequests, "#3");
            Assert.AreEqual(m.Version, decoded.Version, "#4");
            Assert.AreEqual(m.Supports.Count, decoded.Supports.Count, "#5");
            m.Supports.ForEach(delegate(ExtensionSupport s) { Assert.IsTrue(decoded.Supports.Contains(s), "#6:" + s.ToString()); });
        }
        public void HandshakeDecodeTest()
        {
            var message = new ExtendedHandshakeMessage();
            byte[] data = message.Encode();
            var decoded = (ExtendedHandshakeMessage)PeerMessage.DecodeMessage(data, 0, data.Length, _rig.Manager);

            Assert.AreEqual(message.ByteLength, data.Length);
            Assert.AreEqual(message.ByteLength, decoded.ByteLength, "#1");
            Assert.AreEqual(message.LocalPort, decoded.LocalPort, "#2");
            Assert.AreEqual(message.MaxRequests, decoded.MaxRequests, "#3");
            Assert.AreEqual(message.Version, decoded.Version, "#4");
            Assert.AreEqual(message.Supports.Count, decoded.Supports.Count, "#5");

            message.Supports.ForEach(support => Assert.IsTrue(decoded.Supports.Contains(support), string.Format("#6:{0}", support.ToString())));
        }