本文整理汇总了C#中Position.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Position.GetHashCode方法的具体用法?C# Position.GetHashCode怎么用?C# Position.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position.GetHashCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInequality
public static void TestInequality()
{
Position position1 = new Position(File.E, Rank.Two);
Position position2 = new Position(File.B, Rank.Five);
Assert.AreNotEqual(position1, position2, "position1 and position2 are equal");
Assert.False(position1.Equals(position2), "position1.Equals(position2) should be false");
Assert.False(position2.Equals(position1), "position2.Equals(position1) should be false");
Assert.True(position1 != position2, "position1 != position2 should be true");
Assert.True(position2 != position1, "position2 != position1 should be true");
Assert.False(position1 == position2, "position1 == position2 should be false");
Assert.False(position2 == position1, "position2 == position1 should be false");
Assert.AreNotEqual(position1.GetHashCode(), position2.GetHashCode(), "Hash codes of position1 and position2 should be different");
Position position3 = new Position(File.E, Rank.Two);
Position position4 = new Position(File.E, Rank.Five);
Assert.AreNotEqual(position3, position4, "position3 and position4 are equal");
Assert.False(position3.Equals(position4), "position3.Equals(position4) should be false");
Assert.False(position3.Equals(position4), "position4.Equals(position3) should be false");
Assert.True(position3 != position4, "position3 != position4 should be true");
Assert.True(position4 != position3, "position4 != position3 should be true");
Assert.False(position3 == position4, "position3 == position4 should be false");
Assert.False(position4 == position3, "position4 == position3 should be false");
Assert.AreNotEqual(position3.GetHashCode(), position4.GetHashCode(), "Hash codes of position3 and position4 should be different");
Position position5 = new Position(File.E, Rank.Two);
Position position6 = new Position(File.B, Rank.Two);
Assert.AreNotEqual(position5, position6, "position5 and position6 are equal");
Assert.False(position5.Equals(position6), "position5.Equals(position6) should be false");
Assert.False(position6.Equals(position5), "position6.Equals(position5) should be false");
Assert.True(position5 != position6, "position5 != position6 should be true");
Assert.True(position6 != position5, "position6 != position5 should be true");
Assert.False(position5 == position6, "position5 == position6 should be false");
Assert.False(position6 == position5, "position6 == position5 should be false");
Assert.AreNotEqual(position5.GetHashCode(), position6.GetHashCode(), "Hash codes of position5 and position6 should be different");
}
示例2: TestEquality
public static void TestEquality()
{
Position position1 = new Position(File.C, Rank.Six);
Position position2 = new Position(File.C, Rank.Six);
Assert.AreEqual(position1, position2, "position1 and position2 are not equal");
Assert.True(position1.Equals(position2), "position1.Equals(position2) should be true");
Assert.True(position2.Equals(position1), "position2.Equals(position1) should be true");
Assert.True(position1 == position2, "position1 == position2 should be true");
Assert.True(position2 == position1, "position2 == position1 should be true");
Assert.False(position1 != position2, "position1 != position2 should be false");
Assert.False(position2 != position1, "position2 != position1 should be false");
Assert.AreEqual(position1.GetHashCode(), position2.GetHashCode(), "Hash codes should be equal");
}
示例3: TestHashCode
public void TestHashCode()
{
Position position = new Position(13, 15);
int hashCode = 17;
hashCode = (hashCode * 29) + position.X.GetHashCode();
hashCode = (hashCode * 29) + position.Y.GetHashCode();
int actual = position.GetHashCode();
int expected = hashCode;
Assert.AreEqual(expected, actual);
}
示例4: Hashcode
public void Hashcode ()
{
var position = new Position (20, 25);
var position2 = new Position (25, 20);
Assert.AreNotEqual (position.GetHashCode (), position2.GetHashCode ());
}
示例5: GetHashCodeReturnsValueCalculatedFromLineAndColumn
public static void GetHashCodeReturnsValueCalculatedFromLineAndColumn()
{
var a = new Position(4, 2);
var b = new Position(4, 2);
Assert.Equal(a.GetHashCode(), b.GetHashCode());
}