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 HandshakeSupportsTest_Private() { ExtendedHandshakeMessage m = new ExtendedHandshakeMessage(true, 123, 5555); byte[] encoded = m.Encode(); Assert.AreEqual(m.ByteLength, encoded.Length, "#1"); Assert.IsFalse(m.Supports.Exists(s => s.Name.Equals(PeerExchangeMessage.Support.Name)), "#2"); Assert.IsTrue(m.Supports.Exists(s => s.Name.Equals(LTChat.Support.Name)), "#3"); Assert.IsTrue(m.Supports.Exists(s => s.Name.Equals(LTMetadata.Support.Name)), "#4"); }
public void HandshakeSupportsTest() { ExtendedHandshakeMessage m = new ExtendedHandshakeMessage(); byte[] encoded = m.Encode(); Assert.Equal(m.ByteLength, encoded.Length); Assert.True(m.Supports.Exists(delegate(ExtensionSupport s) { return(s.Name.Equals(PeerExchangeMessage.Support.Name)); }), "#2"); Assert.True(m.Supports.Exists(delegate(ExtensionSupport s) { return(s.Name.Equals(LTChat.Support.Name)); }), "#3"); Assert.True(m.Supports.Exists(delegate(ExtensionSupport s) { return(s.Name.Equals(LTMetadata.Support.Name)); }), "#4"); }
public void HandshakeSupportsTest() { ExtendedHandshakeMessage m = new ExtendedHandshakeMessage(false, 1234, 5555); byte[] encoded = m.Encode(); Assert.AreEqual(m.ByteLength, encoded.Length, "#1"); Assert.IsTrue(m.Supports.Exists(s => s.Name.Equals(PeerExchangeMessage.Support.Name)), "#2"); Assert.IsTrue(m.Supports.Exists(s => s.Name.Equals(LTChat.Support.Name)), "#3"); Assert.IsTrue(m.Supports.Exists(s => s.Name.Equals(LTMetadata.Support.Name)), "#4"); Assert.AreEqual(ClientEngine.DefaultMaxPendingRequests, m.MaxRequests, "#5"); }
public void HandshakeDecodeTest() { ExtendedHandshakeMessage m = new ExtendedHandshakeMessage(false, 123, 5555); byte[] data = m.Encode(); ExtendedHandshakeMessage decoded = (ExtendedHandshakeMessage)PeerMessage.DecodeMessage(data, 0, data.Length, null); 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); }); }
public void HandshakeDecodeTest() { ExtendedHandshakeMessage m = new ExtendedHandshakeMessage(); byte[] data = m.Encode(); ExtendedHandshakeMessage decoded = (ExtendedHandshakeMessage)PeerMessage.DecodeMessage(data, 0, data.Length, rig.Manager); Assert.Equal(m.ByteLength, data.Length); Assert.Equal(m.ByteLength, decoded.ByteLength); Assert.Equal(m.LocalPort, decoded.LocalPort); Assert.Equal(m.MaxRequests, decoded.MaxRequests); Assert.Equal(m.Version, decoded.Version); Assert.Equal(m.Supports.Count, decoded.Supports.Count); m.Supports.ForEach(delegate(ExtensionSupport s) { Assert.True(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()))); }