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


C# Card.GetHashCode方法代码示例

本文整理汇总了C#中Card.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Card.GetHashCode方法的具体用法?C# Card.GetHashCode怎么用?C# Card.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Card的用法示例。


在下文中一共展示了Card.GetHashCode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloneShouldReturnObjectWithTheSameHashCode

 public void CloneShouldReturnObjectWithTheSameHashCode()
 {
     var card = new Card(CardSuit.Spade, CardType.Nine);
     var newCard = card.DeepClone();
     Assert.IsNotNull(newCard);
     Assert.AreEqual(card.GetHashCode(), newCard.GetHashCode());
 }
开发者ID:GoranGit,项目名称:TexasHoldemGameEngine,代码行数:7,代码来源:CardTests.cs

示例2: cards_are_different_if_their_value_is_different

        public void cards_are_different_if_their_value_is_different()
        {
            var card1 = new Card(Suit.Spades, 2);
            var card2 = new Card(Suit.Spades, 3);

            card1.ShouldNotEqual(card2);
            card1.GetHashCode().ShouldNotEqual(card2.GetHashCode());
        }
开发者ID:meboz,项目名称:poker,代码行数:8,代码来源:CardTests.cs

示例3: Card_GetHashCode_Test

        public void Card_GetHashCode_Test()
        {
            var card1 = new Card(Rank.Ace, Suite.Club);
            var card2 = new Card(Rank.King, Suite.Spades);

            Assert.AreEqual(9, card1.GetHashCode());
            Assert.AreEqual(108, card2.GetHashCode());
        }
开发者ID:makalainspire,项目名称:Programming,代码行数:8,代码来源:CardTest.cs

示例4: GetHashCode

        public new void GetHashCode()
        {
            Assert.ThrowsExact<ArgumentNullException>(() => Instance.GetHashCode(null));
            Assert.True(Instance.GetHashCode(Card.Joker) == Card.Joker.GetHashCode());

            var aceSpades = new Card(Suit.Spades, Rank.Ace);
            var aceHearts = new Card(Suit.Hearts, Rank.Ace);
            var twoHearts = new Card(Suit.Hearts, Rank.Two);
            Assert.True(Instance.GetHashCode(aceSpades) == aceSpades.GetHashCode());
            Assert.True(Instance.GetHashCode(aceHearts) == aceHearts.GetHashCode());
            Assert.True(Instance.GetHashCode(twoHearts) == twoHearts.GetHashCode());

            Assert.False(Instance.GetHashCode(aceSpades) == aceHearts.GetHashCode());
            Assert.False(Instance.GetHashCode(aceSpades) == twoHearts.GetHashCode());
            Assert.False(Instance.GetHashCode(aceHearts) == aceSpades.GetHashCode());
            Assert.False(Instance.GetHashCode(aceHearts) == twoHearts.GetHashCode());
            Assert.False(Instance.GetHashCode(twoHearts) == aceSpades.GetHashCode());
            Assert.False(Instance.GetHashCode(twoHearts) == aceHearts.GetHashCode());
        }
开发者ID:LazyBui,项目名称:BoringCardLib,代码行数:19,代码来源:DefaultCardComparerTest.cs

示例5: EachCardHasDifferentHashCode

        public void EachCardHasDifferentHashCode()
        {
            var cards = new Dictionary<int, Card>();

            foreach (CardSuit cardColor in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardType cardType in Enum.GetValues(typeof(CardType)))
                {
                    var card = new Card(cardType, cardColor);
                    var hashCode = card.GetHashCode();
                    if (cards.ContainsKey(hashCode))
                    {
                        Assert.Fail("Found 2 cards with the same hash code: {0} and {1}", card, cards[hashCode]);
                    }

                    cards.Add(hashCode, card);
                }
            }
        }
开发者ID:razsilev,项目名称:TelerikAcademy_Homework,代码行数:19,代码来源:CardTests.cs

示例6: FromHashCodeShouldCreateCardsWithTheGivenHashCode

 public void FromHashCodeShouldCreateCardsWithTheGivenHashCode()
 {
     foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
     {
         foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
         {
             var card = new Card(cardSuitValue, cardTypeValue);
             var hashCode = card.GetHashCode();
             var newCard = Card.FromHashCode(hashCode);
             Assert.AreEqual(card, newCard);
         }
     }
 }
开发者ID:GoranGit,项目名称:TexasHoldemGameEngine,代码行数:13,代码来源:CardTests.cs

示例7: GetHashCodeShouldReturnDifferentValidValueForEachCardCombination

 public void GetHashCodeShouldReturnDifferentValidValueForEachCardCombination()
 {
     var values = new HashSet<int>();
     foreach (CardSuit cardSuitValue in Enum.GetValues(typeof(CardSuit)))
     {
         foreach (CardType cardTypeValue in Enum.GetValues(typeof(CardType)))
         {
             var card = new Card(cardSuitValue, cardTypeValue);
             var cardHashCode = card.GetHashCode();
             Assert.IsFalse(
                 values.Contains(cardHashCode),
                 $"Duplicate hash code \"{cardHashCode}\" for card \"{card}\"");
             values.Add(cardHashCode);
         }
     }
 }
开发者ID:GoranGit,项目名称:TexasHoldemGameEngine,代码行数:16,代码来源:CardTests.cs

示例8: GetHashCodeShouldReturn52ForKingOfSpades

 public void GetHashCodeShouldReturn52ForKingOfSpades(int expectedHashCode, CardSuit cardSuit, CardType cardType)
 {
     var card = new Card(cardSuit, cardType);
     var hashCode = card.GetHashCode();
     Assert.AreEqual(expectedHashCode, hashCode);
 }
开发者ID:GoranGit,项目名称:TexasHoldemGameEngine,代码行数:6,代码来源:CardTests.cs


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