public void CloneShouldReturnObjectWithTheSameHashCode() { var card = new Card(CardSuit.Spade, CardType.Nine); var newCard = card.DeepClone(); Assert.IsNotNull(newCard); Assert.AreEqual(card.GetHashCode(), newCard.GetHashCode()); }
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); } } }
public void GetHashCodeShouldReturn52ForKingOfSpades() { var card = new Card(CardSuit.Spade, CardType.King); var hashCode = card.GetHashCode(); Assert.AreEqual(52, hashCode); }
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); } } }
public void GetHashCodeShouldReturn1ForAceOfClubs() { var card = new Card(CardSuit.Club, CardType.Ace); var hashCode = card.GetHashCode(); Assert.AreEqual(1, hashCode); }