当前位置: 首页>>代码示例>>C#>>正文


C# Position.GetHashCode方法代码示例

本文整理汇总了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");
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:35,代码来源:PositionTests.cs

示例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");
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:13,代码来源:PositionTests.cs

示例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);
        }
开发者ID:Anubis-Black,项目名称:TeamIodine,代码行数:14,代码来源:TestPosition.cs

示例4: Hashcode

		public void Hashcode ()
		{
			var position = new Position (20, 25);
			var position2 = new Position (25, 20);
			Assert.AreNotEqual (position.GetHashCode (), position2.GetHashCode ());
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:6,代码来源:PositionTests.cs

示例5: GetHashCodeReturnsValueCalculatedFromLineAndColumn

 public static void GetHashCodeReturnsValueCalculatedFromLineAndColumn()
 {
     var a = new Position(4, 2);
     var b = new Position(4, 2);
     Assert.Equal(a.GetHashCode(), b.GetHashCode());
 }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:6,代码来源:PositionTest.cs


注:本文中的Position.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。