本文整理汇总了C#中Location.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Location.GetHashCode方法的具体用法?C# Location.GetHashCode怎么用?C# Location.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEquals
public void TestEquals()
{
var loc1 = new Location(1, 2);
var loc2 = new Location(1, 2);
var loc3 = new Location(1, 3);
Assert.AreEqual(loc1, loc2);
Assert.AreEqual(loc1.GetHashCode(), loc2.GetHashCode());
Assert.AreNotEqual(loc1, loc3);
Assert.AreNotEqual(loc1.GetHashCode(), loc3.GetHashCode());
}
示例2: locationXYRegionHandle
public void locationXYRegionHandle()
{
Location TestLocation1 = new Location(256000,256000);
Location TestLocation2 = new Location(1099511628032000);
Assert.That(TestLocation1 == TestLocation2);
Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
Assert.That(TestLocation2.RegionHandle == 1099511628032000,
"Location RegionHandle Property didn't match regionhandle provided in constructor");
TestLocation1 = new Location(256001, 256001);
TestLocation2 = new Location(1099511628032000);
Assert.That(TestLocation1 != TestLocation2);
Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");
Location TestLocation3;
object cln = TestLocation2.Clone();
TestLocation3 = (Location) cln;
Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y,
"Cloned Location values do not match");
Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
}
示例3: CanCompareForEquality
public void CanCompareForEquality()
{
Location loc1 = new Location(85.6789, 92.4517);
Location loc2 = new Location(85.6789, 92.4517);
Assert.True(loc1.Equals(loc2));
Assert.Equal(loc1.GetHashCode(), loc2.GetHashCode());
}