本文整理汇总了C#中Peer.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Peer.GetHashCode方法的具体用法?C# Peer.GetHashCode怎么用?C# Peer.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peer
的用法示例。
在下文中一共展示了Peer.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public void Test()
{
Peer peer = new Peer();
string internetProtocolAddressStr1 = "127.255.0.16";
string internetProtocolAddressStr2 = "1.2.3.4";
int port1 = 12345678;
int port2 = 1234;
IPAddress address = IPAddress.Parse(internetProtocolAddressStr1);
// Test Constructor
Peer peer2 = new Peer(address, port1);
Assert.AreEqual(internetProtocolAddressStr1, peer2.IP);
Assert.AreEqual(port1, peer2.Port);
Peer peer3 = new Peer(internetProtocolAddressStr1, port1);
Assert.AreEqual(internetProtocolAddressStr1, peer3.IP);
Assert.AreEqual(port1, peer3.Port);
Assert.IsTrue(peer2.Equals(peer3));
Assert.IsTrue(peer3.Equals(peer2));
Assert.AreEqual(peer2.GetHashCode(), peer3.GetHashCode());
peer2.IP = internetProtocolAddressStr2;
Assert.IsFalse(peer2.Equals(peer3));
Assert.IsFalse(peer3.Equals(peer2));
Assert.AreNotEqual(peer2.GetHashCode(), peer3.GetHashCode());
peer2.IP = internetProtocolAddressStr1;
Assert.IsTrue(peer2.Equals(peer3));
Assert.IsTrue(peer3.Equals(peer2));
Assert.AreEqual(peer2.GetHashCode(), peer3.GetHashCode());
peer3.Port = port2;
Assert.IsFalse(peer2.Equals(peer3));
Assert.IsFalse(peer3.Equals(peer2));
Assert.AreNotEqual(peer2.GetHashCode(), peer3.GetHashCode());
}