本文整理汇总了C#中SourceLocation.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation.GetHashCode方法的具体用法?C# SourceLocation.GetHashCode怎么用?C# SourceLocation.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceLocation
的用法示例。
在下文中一共展示了SourceLocation.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHashCode_ReturnsSameValue_WhenEqual
public void GetHashCode_ReturnsSameValue_WhenEqual(string path)
{
// Arrange
var sourceLocationA = new SourceLocation(path, 10, 3, 4);
var sourceLocationB = new SourceLocation(path, 10, 3, 4);
var sourceLocationC = new SourceLocation(path, 10, 45, 8754);
// Act
var hashCodeA = sourceLocationA.GetHashCode();
var hashCodeB = sourceLocationB.GetHashCode();
var hashCodeC = sourceLocationC.GetHashCode();
// Assert
Assert.Equal(hashCodeA, hashCodeB);
Assert.Equal(hashCodeA, hashCodeC);
}
示例2: TestEqualSourceLocations
public void TestEqualSourceLocations()
{
string sampleProgram = @"class
end class";
SyntaxTree syntaxTree = SyntaxFactory.ParseSyntaxTree(sampleProgram);
SyntaxTree tree2 = SyntaxFactory.ParseSyntaxTree(sampleProgram);
SourceLocation loc1 = new SourceLocation(syntaxTree, new TextSpan(3, 4));
SourceLocation loc2 = new SourceLocation(syntaxTree, new TextSpan(3, 4));
SourceLocation loc3 = new SourceLocation(syntaxTree, new TextSpan(3, 7));
SourceLocation loc4 = new SourceLocation(tree2, new TextSpan(3, 4));
Assert.Equal(loc1, loc2);
Assert.Equal(loc1.GetHashCode(), loc2.GetHashCode());
Assert.NotEqual(loc1, loc3);
Assert.NotEqual(loc3, loc4);
}