本文整理汇总了C#中ConnectionId.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionId.Equals方法的具体用法?C# ConnectionId.Equals怎么用?C# ConnectionId.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionId
的用法示例。
在下文中一共展示了ConnectionId.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_should_return_expected_result
public void Equals_should_return_expected_result(
int port1,
int localValue1,
int serverValue1,
int port2,
int localValue2,
int serverValue2,
bool expectedEqualsResult,
bool expectedStructurallyEqualsResult)
{
var clusterId = new ClusterId();
var serverId1 = new ServerId(clusterId, new DnsEndPoint("localhost", port1));
var serverId2 = new ServerId(clusterId, new DnsEndPoint("localhost", port2));
var subject1 = new ConnectionId(serverId1, localValue1).WithServerValue(serverValue1);
var subject2 = new ConnectionId(serverId2, localValue2).WithServerValue(serverValue2);
// note: Equals ignores the server values and StructurallyEquals compares all fields
var equalsResult1 = subject1.Equals(subject2);
var equalsResult2 = subject2.Equals(subject1);
var structurallyEqualsResult1 = subject1.StructurallyEquals(subject2);
var structurallyEqualsResult2 = subject2.StructurallyEquals(subject1);
var hashCode1 = subject1.GetHashCode();
var hashCode2 = subject2.GetHashCode();
equalsResult1.Should().Be(expectedEqualsResult);
equalsResult2.Should().Be(expectedEqualsResult);
structurallyEqualsResult1.Should().Be(expectedStructurallyEqualsResult);
structurallyEqualsResult2.Should().Be(expectedStructurallyEqualsResult);
(hashCode1 == hashCode2).Should().Be(expectedEqualsResult);
}
示例2: Equals_should_return_correct_results
public void Equals_should_return_correct_results()
{
var serverId1 = __serverId;
var serverId2 = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27018));
var localValue1 = 10;
var localValue2 = 11;
var subject1 = new ConnectionId(serverId1, localValue1);
var subject2 = new ConnectionId(serverId1, localValue1);
var subject3 = new ConnectionId(serverId1, localValue2);
var subject4 = new ConnectionId(serverId2, localValue1);
subject1.Equals(subject2).Should().BeTrue();
subject1.Equals(subject3).Should().BeFalse();
subject1.Equals(subject4).Should().BeFalse();
}