本文整理汇总了C#中ConnectionId.StructurallyEquals方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionId.StructurallyEquals方法的具体用法?C# ConnectionId.StructurallyEquals怎么用?C# ConnectionId.StructurallyEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionId
的用法示例。
在下文中一共展示了ConnectionId.StructurallyEquals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}