public static void Equals_Compare_Success() { SocketAddress sa1 = new SocketAddress(AddressFamily.InterNetwork, 64); SocketAddress sa2 = new SocketAddress(AddressFamily.InterNetwork, 64); SocketAddress sa3 = new SocketAddress(AddressFamily.InterNetworkV6, 64); SocketAddress sa4 = new SocketAddress(AddressFamily.InterNetwork, 60000); Assert.False(sa1.Equals(null)); Assert.False(sa1.Equals("")); Assert.Equal(sa1, sa2); Assert.Equal(sa2, sa1); Assert.Equal(sa1.GetHashCode(), sa2.GetHashCode()); Assert.NotEqual(sa1, sa3); Assert.NotEqual(sa1.GetHashCode(), sa3.GetHashCode()); Assert.NotEqual(sa1, sa4); }
public override bool Equals(object obj) { MutableIPEndPoint iPEndPoint = obj as MutableIPEndPoint; return(null != iPEndPoint && socketAddress.Equals(iPEndPoint.socketAddress)); }