예제 #1
0
        public void HandToStringTestThreeCards()
        {
            Hand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Two, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Diamonds),
                new Card(CardFace.Four, CardSuit.Spades)
            });
            string expected = "2♥ 3♦ 4♠";
            string actual   = hand.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void HandToStringTestFourCards()
        {
            Hand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Five, CardSuit.Hearts),
                new Card(CardFace.Six, CardSuit.Diamonds),
                new Card(CardFace.Eight, CardSuit.Spades),
                new Card(CardFace.King, CardSuit.Spades)
            });
            string expected = "5♥ 6♦ 8♠ K♠";
            string actual   = hand.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
파일: HandTests.cs 프로젝트: dhija/Telerik
        public void ToString_TestFormatting()
        {
            var cards = new List <ICard>()
            {
                new Card(CardFace.Ace, CardSuit.Clubs),
                new Card(CardFace.Ace, CardSuit.Diamonds),
                new Card(CardFace.King, CardSuit.Hearts),
                new Card(CardFace.King, CardSuit.Spades),
                new Card(CardFace.Seven, CardSuit.Diamonds),
            };
            var hand = new Hand(cards);

            Assert.AreEqual("Ace♣, Ace♦, King♥, King♠, 7♦", hand.ToString());
        }
예제 #4
0
        public void ToStringWithFiveCards()
        {
            Hand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Three, CardSuit.Diamonds),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Seven, CardSuit.Clubs),
                new Card(CardFace.Nine, CardSuit.Spades),
                new Card(CardFace.Ten, CardSuit.Clubs)
            });
            string result = hand.ToString();

            Assert.AreEqual("3♦ A♥ 7♣ 9♠ 10♣", result);
        }
예제 #5
0
        public void HandToStringTestFiveSameCards()
        {
            Hand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Ace, CardSuit.Hearts)
            });
            string expected = "A♥ A♥ A♥ A♥ A♥";
            string actual   = hand.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void SixOtDiamondsHandTest()
        {
            var sixOfDiamonds = new Card(CardFace.Six, CardSuit.Diamonds);

            var cards = new List <ICard>()
            {
                sixOfDiamonds
            };

            var hand = new Hand(cards);

            var expectedResult = sixOfDiamonds.ToString();

            Assert.AreEqual(expectedResult, hand.ToString());
        }
        public void TestSameCards()
        {
            Card          cardOne   = new Card(CardFace.Ten, CardSuit.Clubs);
            Card          cardTwo   = new Card(CardFace.Ten, CardSuit.Clubs);
            Card          cardThree = new Card(CardFace.Ten, CardSuit.Clubs);
            IList <ICard> cards     = new List <ICard>();

            cards.Add(cardOne);
            cards.Add(cardTwo);
            cards.Add(cardThree);
            Hand   hand         = new Hand(cards);
            string handToString = hand.ToString();

            Assert.AreEqual("10♣10♣10♣", handToString, "ToString() method in class Hand is not working correctly.");
        }
예제 #8
0
        public void HandToStringTestFiveDifferentCards()
        {
            Hand hand = new Hand(new List <ICard>()
            {
                new Card(CardFace.Ace, CardSuit.Hearts),
                new Card(CardFace.Two, CardSuit.Spades),
                new Card(CardFace.Ten, CardSuit.Clubs),
                new Card(CardFace.Seven, CardSuit.Diamonds),
                new Card(CardFace.Jack, CardSuit.Hearts)
            });
            string expected = "A♥ 2♠ 10♣ 7♦ J♥";
            string actual   = hand.ToString();

            Assert.AreEqual(expected, actual);
        }
예제 #9
0
        public void TestSameCards()
        {
            Card card = new Card(CardFace.Ten, CardSuit.Hearts);

            IList <ICard> cards = new List <ICard>();

            for (int i = 0; i < 5; i++)
            {
                cards.Add(card);
            }

            Hand hand = new Hand(cards);

            Assert.AreEqual("10♥10♥10♥10♥10♥", hand.ToString(), "ToString() method in class Hand is not working correctly.");
        }
예제 #10
0
        public void TestToStringMethodsOfHandClassIfReturnCorrectValue()
        {
            var correctString = new StringBuilder();
            var cardList      = new List <ICard>();

            for (int i = 0; i < Hand.CardsInHand; i++)
            {
                var card = new Card(CardFace.Ace, CardSuit.Clubs);
                correctString.AppendLine(card.ToString());
                cardList.Add((ICard)card);
            }
            var handOfCardsString = correctString.ToString();
            var hand = new Hand(cardList);

            Assert.IsTrue(handOfCardsString == hand.ToString());
        }
예제 #11
0
        public void TwoOfClubsAndQueenOfHeartsHandTest()
        {
            var twoOfClubs     = new Card(CardFace.Two, CardSuit.Clubs);
            var queenOfHearths = new Card(CardFace.Queen, CardSuit.Hearts);

            IList <ICard> cards = new List <ICard>()
            {
                twoOfClubs,
                queenOfHearths
            };

            var hand = new Hand(cards);

            var expectedResult = twoOfClubs.ToString() + ", " + queenOfHearths.ToString();

            Assert.AreEqual(expectedResult, hand.ToString());
        }
예제 #12
0
        public void ThreeOfHeartsAceOfClubsAndKingOfClubsHandTest()
        {
            var threeOfHearths = new Card(CardFace.Three, CardSuit.Hearts);
            var aceOfClubs     = new Card(CardFace.Ace, CardSuit.Clubs);
            var kingOfClubs    = new Card(CardFace.King, CardSuit.Clubs);

            IList <ICard> cards = new List <ICard>()
            {
                threeOfHearths,
                aceOfClubs,
                kingOfClubs
            };

            var hand = new Hand(cards);

            var expectedResult = threeOfHearths.ToString() + ", " + aceOfClubs.ToString() + ", " + kingOfClubs.ToString();

            Assert.AreEqual(expectedResult, hand.ToString());
        }
예제 #13
0
        public void TestValidHand()
        {
            Card cardOne   = new Card(CardFace.King, CardSuit.Diamonds);
            Card cardTwo   = new Card(CardFace.Jack, CardSuit.Hearts);
            Card cardThree = new Card(CardFace.Five, CardSuit.Spades);
            Card cardFour  = new Card(CardFace.Ace, CardSuit.Clubs);
            Card cardFive  = new Card(CardFace.Ten, CardSuit.Clubs);

            IList <ICard> cards = new List <ICard>();

            cards.Add(cardOne);
            cards.Add(cardTwo);
            cards.Add(cardThree);
            cards.Add(cardFour);
            cards.Add(cardFive);
            Hand hand = new Hand(cards);

            Assert.AreEqual("King♦Jack♥5♠Ace♣10♣", hand.ToString(), "ToString() method in class Hand is not working correctly.");
        }
        public void TestHandToStringWithKingSpadesThreeClubsTenClubsQueenDiamondsAndSixClubs()
        {
            var card1 = new Card(CardFace.King, CardSuit.Spades);
            var card2 = new Card(CardFace.Three, CardSuit.Clubs);
            var card3 = new Card(CardFace.Ten, CardSuit.Clubs);
            var card4 = new Card(CardFace.Queen, CardSuit.Diamonds);
            var card5 = new Card(CardFace.Six, CardSuit.Clubs);

            var cardList = new List <ICard>();

            cardList.Add(card1);
            cardList.Add(card2);
            cardList.Add(card3);
            cardList.Add(card4);
            cardList.Add(card5);

            Hand   hand          = new Hand(cardList);
            string correctResult = hand.Cards[0].ToString() + hand.Cards[1] + hand.Cards[2] + hand.Cards[3] + hand.Cards[4];

            Assert.AreEqual(hand.ToString(), correctResult);
        }
예제 #15
0
        public void Test_HandToString()
        {
            Deck deck = new Deck();

            Card[] testCards = new Card[5];
            testCards[0] = new Card("AS");
            testCards[1] = new Card("KC");
            testCards[2] = new Card("QD");
            testCards[3] = new Card("JH");
            testCards[4] = new Card("10S");
            //testCards[5] = new Card("9H");

            Hand   hand     = new Hand(testCards);
            string expected = "AS, KC, QD, JH, 10S";

            Assert.AreEqual(expected, hand.ToString());

            testCards[0] = new Card("AS");
            testCards[1] = new Card("AS");
            testCards[2] = new Card("AS");
            testCards[3] = new Card("AS");
            testCards[4] = new Card("AS");

            hand     = new Hand(testCards);
            expected = "AS, AS, AS, AS, AS";

            Assert.AreEqual(expected, hand.ToString());

            testCards[0] = new Card("AS");
            testCards[1] = new Card("AH");
            testCards[2] = new Card("AD");
            testCards[3] = new Card("AC");
            testCards[4] = new Card("2D");

            hand     = new Hand(testCards);
            expected = "AS, AH, AD, AC, 2D";

            Assert.AreEqual(expected, hand.ToString());
        }
예제 #16
0
        public void ToString()
        {
            var cards = new List <ICard>();

            cards.Add(new Card(CardFace.Jack, CardSuit.Diamonds));
            cards.Add(new Card(CardFace.King, CardSuit.Clubs));
            cards.Add(new Card(CardFace.Ace, CardSuit.Hearts));
            cards.Add(new Card(CardFace.Jack, CardSuit.Spades));
            cards.Add(new Card(CardFace.Five, CardSuit.Clubs));

            var hand = new Hand(cards);

            var actual = hand.ToString();
            var sb     = new StringBuilder();

            foreach (var card in hand.Cards)
            {
                sb.AppendLine(card.ToString());
            }

            var expected = sb.ToString();

            Assert.AreEqual(actual, expected);
        }
예제 #17
0
        public void TestEmptyHand()
        {
            Hand hand = new Hand(new List <ICard>());

            Assert.AreEqual(string.Empty, hand.ToString(), "ToString() method in class Hand is not working correctly.");
        }
예제 #18
0
 public void HandToStringTestZeroCards()
 {
     Hand   hand   = new Hand(new List <ICard>());
     string actual = hand.ToString();
 }