Inheritance: ICard
 public void ToStringJackHearts()
 {
     Card card = new Card(CardFace.Jack, CardSuit.Hearts);
     var excpected = "J♥";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
 public void ToStringTenDiamons()
 {
     Card card = new Card(CardFace.Ten, CardSuit.Diamonds);
     var excpected = "10♦";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Beispiel #3
0
        public void TestCardToString()
        {
            Card card = new Card(CardFace.Ace, CardSuit.Hearts);
            string expected = "Ace of Hearts";

            Assert.AreEqual(expected, card.ToString());
        }
 public void ToStringAceSpades()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Spades);
     var excpected = "A♠";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Beispiel #5
0
        public void TestCardShouldCompareCorrectly_DifferentCards()
        {
            var cardA = new Card(CardFace.Jack, CardSuit.Clubs);
            var cardB = new Card(CardFace.Ace, CardSuit.Hearts);

            Assert.IsFalse(cardA.Equals(cardB));
        }
Beispiel #6
0
        public void TestCardShouldCompareCorrectly_EqualCards()
        {
            var cardA = new Card(CardFace.Jack, CardSuit.Clubs);
            var cardB = new Card(CardFace.Jack, CardSuit.Clubs);

            Assert.IsTrue(cardA.Equals(cardB));
        }
        static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(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),
            });
            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsStraight(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPair(hand));
            Console.WriteLine(checker.IsStraightFlush(hand));
            Console.WriteLine(checker.IsFlush(hand));
            Console.WriteLine(checker.IsFourOfAKind(hand));
            Console.WriteLine(checker.IsThreeOfAKind(hand));
            Console.WriteLine(checker.IsHighCard(hand));
            Console.WriteLine(checker.IsFullHouse(hand));
        }
Beispiel #8
0
        internal static void Main()
        {
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(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),
            });
            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine(checker.IsValidHand(hand));
            Console.WriteLine(checker.IsOnePair(hand));
            Console.WriteLine(checker.IsTwoPairs(hand));

            int a = 5;
            int b = 6;

            Console.WriteLine(b.CompareTo(a));
        }
 public void ToStringThreeOfHearts()
 {
     Card card = new Card(CardFace.Three, CardSuit.Hearts);
     string actual = card.ToString();
     string expected = "3♥";
     Assert.AreEqual(actual, expected);
 }
 public void TestCompareHandsFirstHand()
 {
     Card cardOne = new Card(CardFace.Ace, CardSuit.Diamonds);
     Card cardTwo = new Card(CardFace.Ace, CardSuit.Hearts);
     Card cardThree = new Card(CardFace.Five, CardSuit.Spades);
     Card cardFour = new Card(CardFace.Ace, CardSuit.Clubs);
     Card cardFive = new Card(CardFace.Ace, CardSuit.Spades);
     IList<ICard> cardsOne = new List<ICard>();
     cardsOne.Add(cardOne);
     cardsOne.Add(cardTwo);
     cardsOne.Add(cardThree);
     cardsOne.Add(cardFour);
     cardsOne.Add(cardFive);
     Hand handOne = new Hand(cardsOne);
     Card cardSix = new Card(CardFace.Two, CardSuit.Diamonds);
     Card cardSeven = new Card(CardFace.Jack, CardSuit.Hearts);
     Card cardEight = new Card(CardFace.Five, CardSuit.Spades);
     Card cardNine = new Card(CardFace.Ace, CardSuit.Clubs);
     Card cardTen = new Card(CardFace.Ten, CardSuit.Clubs);
     IList<ICard> cardsTwo = new List<ICard>();
     cardsTwo.Add(cardSix);
     cardsTwo.Add(cardSeven);
     cardsTwo.Add(cardEight);
     cardsTwo.Add(cardNine);
     cardsTwo.Add(cardTen);
     Hand handTwo = new Hand(cardsTwo);
     PokerHandsChecker poker = new PokerHandsChecker();
     int result = poker.CompareHands(handOne, handTwo);
     Assert.AreEqual(1, result, "CompareHands() method in class PokerHandsChecker is not working correctly.");
 }
 public void ToStringJackOfClubs()
 {
     Card card = new Card(CardFace.Jack, CardSuit.Clubs);
     string actual = card.ToString();
     string expected = "J♣";
     Assert.AreEqual(actual, expected);
 }
 public void ToStringAceOfSpadesTest()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Spades);
     string actual = card.ToString();
     string expected = "A♠";
     Assert.AreEqual(actual, expected);
 }
Beispiel #13
0
 public void TestAceHeartToString()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Hearts);
     string expected = "A♥";
     string result = card.ToString();
     Assert.AreEqual(expected, result);
 }
 public void ToStringTwoClubs()
 {
     Card card = new Card(CardFace.Two, CardSuit.Clubs);
     var excpected = "2♣";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
        public void PokerTestToStringAceHearts()
        {
            Card myCard = new Card(CardFace.Ace, CardSuit.Hearts);
            string result = myCard.ToString();

            Assert.AreEqual("A♥", result);
        }
        public void TestToStringTwoOfDiamonds()
        {
            Card card = new Card(CardFace.Two, CardSuit.Diamonds);
            string result = "2" + this.diamond;

            Assert.AreEqual(card.ToString(), result);
        }
        public void TestToStringJackOfHearts()
        {
            Card card = new Card(CardFace.Jack, CardSuit.Hearts);
            string result = "J" + this.heart;

            Assert.AreEqual(card.ToString(), result);
        }
        public void TestToStringQueenOfSpades()
        {
            Card card = new Card(CardFace.Queen, CardSuit.Spades);
            string result = "Q" + this.spade;

            Assert.AreEqual(card.ToString(), result);
        }
Beispiel #19
0
 public void Card_ToString_ShouldReturnCorrectSuit_King()
 {
     Card card = new Card(CardFace.King, CardSuit.Spades);
     var cardToString = card.ToString();
     var length = cardToString.Length;
     Assert.AreEqual("King", cardToString.Substring(0, 4));
 }
        public void TestToStringAceOfClubs()
        {
            Card card = new Card(CardFace.Ace, CardSuit.Clubs);
            string result = "A" + this.club;

            Assert.AreEqual(card.ToString(), result);
        }
Beispiel #21
0
 public void Card_ToString_ShouldReturnCorrectFace_Five()
 {
     Card card = new Card(CardFace.Five, CardSuit.Diamonds);
     var cardToString = card.ToString();
     var length = cardToString.Length;
     Assert.AreEqual("Five", cardToString.Substring(0, 4));
 }
Beispiel #22
0
 public void Card_ToString_ShouldReturnCorrectFace_Jack()
 {
     Card card = new Card(CardFace.Jack, CardSuit.Clubs);
     var cardToString = card.ToString();
     var length = cardToString.Length;
     Assert.AreEqual("Jack", cardToString.Substring(0, 4));
 }
Beispiel #23
0
 public void CardToStringTestTenOfDiamonds()
 {
     Card card = new Card(CardFace.Ten, CardSuit.Diamonds);
     string expected = "10♦";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Beispiel #24
0
 public void CardToStringTestTwoOfSpades()
 {
     Card card = new Card(CardFace.Two, CardSuit.Spades);
     string expected = "2♠";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Beispiel #25
0
 public void CardToStringTestAceOfHearts()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Hearts);
     string expected = "A♥";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Beispiel #26
0
 public void CardToStringTestNineOfClubs()
 {
     Card card = new Card(CardFace.Nine, CardSuit.Clubs);
     string expected = "9♣";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
        static void Main()
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            ICard card = new Card(CardFace.Ace, CardSuit.Clubs);
            Console.WriteLine(card);

            IHand hand = new Hand(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),
            });

            IHand hand2 = new Hand(new List<ICard>() 
            { 
                new Card(CardFace.Two, CardSuit.Clubs),
                new Card(CardFace.Two, CardSuit.Diamonds),
                new Card(CardFace.Three, CardSuit.Hearts),
                new Card(CardFace.Three, CardSuit.Spades),
                new Card(CardFace.Two, CardSuit.Hearts),
            });

            Console.WriteLine(hand);

            IPokerHandsChecker checker = new PokerHandsChecker();
            Console.WriteLine("Is valid hand: " + checker.IsValidHand(hand));
            Console.WriteLine("Is one pair: " + checker.IsOnePair(hand));
            Console.WriteLine("Is two pairs: " + checker.IsTwoPair(hand));

            Console.WriteLine(Environment.NewLine + "Compare hands. 1 for first hand. -1 for second hand. 0 for same hands");
            Console.WriteLine("Hand: {0}, Hand2: {1} Compare: {2}", hand, hand2, checker.CompareHands(hand, hand2));
        }
        public void PokerTestToStringTwoClubs()
        {
            Card myCard = new Card(CardFace.Two, CardSuit.Clubs);
            string result = myCard.ToString();

            Assert.AreEqual("2♣", result);
        }
        public void PokerTestToStringSevenDiamonds()
        {
            Card myCard = new Card(CardFace.Seven, CardSuit.Diamonds);
            string result = myCard.ToString();

            Assert.AreEqual("7♦", result);
        }
        public void PokerTestToStringQueenSpades()
        {
            Card myCard = new Card(CardFace.Queen, CardSuit.Spades);
            string result = myCard.ToString();

            Assert.AreEqual("Q♠", result);
        }
        public void TestCardToStringWithInvalidData5()
        {
            const CardFace face = CardFace.Ace;
            const CardSuit suit = CardSuit.Diamonds;
            var            card = new Poker.Card(face, suit);

            Assert.AreNotEqual(string.Format("{0},{1}", face, suit), card.ToString());
        }
        public void TestCardToStringWithValidData()
        {
            var cardFace = new List <CardFace>
            {
                CardFace.Two,
                CardFace.Three,
                CardFace.Four,
                CardFace.Five,
                CardFace.Six,
                CardFace.Seven,
                CardFace.Eight,
                CardFace.Nine,
                CardFace.Ten,
                CardFace.Jack,
                CardFace.Queen,
                CardFace.King,
                CardFace.Ace
            };

            var cardSuit = new List <CardSuit>
            {
                CardSuit.Clubs,
                CardSuit.Diamonds,
                CardSuit.Hearts,
                CardSuit.Spades
            };

            foreach (var face in cardFace)
            {
                foreach (var suit in cardSuit)
                {
                    var card = new Poker.Card(face, suit);
                    Assert.AreEqual(string.Format("{0}{1}", face, suit), card.ToString());
                }
            }
        }