Пример #1
0
 public void CardIsLessThan()
 {
     IComparable card1 = new Card(Rank.Ace, Suit.Clubs);
     IComparable card2 = new Card(Rank.Two, Suit.Diamonds);
     var result = card1.CompareTo(card2);
     Assert.IsTrue(result < 0);
 }
Пример #2
0
 public void CardsAreEqual()
 {
     IComparable card1 = new Card(Rank.Ace, Suit.Clubs);
     IComparable card2 = new Card(Rank.Ace, Suit.Diamonds);
     var result = card1.CompareTo(card2);
     Assert.AreEqual(result, 0);
 }
Пример #3
0
        public void HaveOneCardReturnsCardAsString()
        {
            var card = new Card(Rank.Ace, Suit.Clubs);

            var hand = new Hand();
            hand.AddCard(card);
            Assert.AreEqual(hand.ToString(), card.ToString());
        }
Пример #4
0
        public void HaveTwoCardsReturnsTwoCommaSeparatedCardsInAscendingOrderAsString()
        {
            var card1 = new Card(Rank.Three, Suit.Clubs);
            var card2 = new Card(Rank.Two, Suit.Clubs);

            var hand = new Hand();
            hand.AddCard(card1);
            hand.AddCard(card2);
            Assert.AreEqual(hand.ToString(), card2.ToString() + ", " + card1.ToString());
        }
Пример #5
0
 public void ReturnsAceOfClubsString()
 {
     var card = new Card(Rank.Ace, Suit.Clubs);
     var result = card.ToString();
     Assert.AreEqual(result, "A♣");
 }
Пример #6
0
 public void ConstructorInitializeSuit()
 {
     var card = new Card(Rank.Ace, Suit.Clubs);
     Assert.AreEqual(card.Suit, Suit.Clubs);
 }
Пример #7
0
 public void CompareWithWrongTypeThrows()
 {
     IComparable card1 = new Card(Rank.Ace, Suit.Clubs);
     var result = card1.CompareTo(new object());
 }
Пример #8
0
 public void CompareToNullThrows()
 {
     IComparable card1 = new Card(Rank.Ace, Suit.Clubs);
     var result = card1.CompareTo(null);
 }
Пример #9
0
 public void ReturnTwoOfHeartsString()
 {
     var card = new Card(Rank.Two, Suit.Hearts);
     var result = card.ToString();
     Assert.AreEqual(result, "2♥");
 }
Пример #10
0
 public void ReturnsTenOfDiamondsString()
 {
     var card = new Card(Rank.Ten, Suit.Diamonds);
     var result = card.ToString();
     Assert.AreEqual(result, "10♦");
 }
Пример #11
0
 public void ReturnsKingOfSpadesString()
 {
     var card = new Card(Rank.Ten, Suit.Spades);
     var result = card.ToString();
     Assert.AreEqual(result, "10♠");
 }
Пример #12
0
 public void IndexerReturnsOnZeroBasedIndex()
 {
     var card = new Card(Rank.Ace, Suit.Clubs);
     var hand = new Hand();
     hand.AddCard(card);
     Assert.AreEqual(card, hand[0]);
 }
Пример #13
0
        public void IndexerReturnsCardsInAscendingOrder()
        {
            var card1 = new Card(Rank.Three, Suit.Clubs);
            var card2 = new Card(Rank.Two, Suit.Clubs);

            var hand = new Hand();
            hand.AddCard(card1);
            hand.AddCard(card2);
            Assert.AreEqual(card2, hand[0]);
        }
Пример #14
0
        public void IndexerReturnsCardsByIndex()
        {
            var higherCardAdded = new Card(Rank.King, Suit.Clubs);

            var hand = new Hand();
            hand.AddCard(higherCardAdded);
            hand.AddCard(new Card(Rank.Queen, Suit.Clubs));
            hand.AddCard(new Card(Rank.Jack, Suit.Clubs));
            Assert.AreEqual(higherCardAdded, hand[2]);
        }
Пример #15
0
 public void AddCard(Card card)
 {
     _cards.Add(card);
     _cards.Sort();
 }