コード例 #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
ファイル: Hand.cs プロジェクト: mmacedo/dojo-2011-08-poker
 public void AddCard(Card card)
 {
     _cards.Add(card);
     _cards.Sort();
 }