ToString() public method

public ToString ( ) : string
return string
 public void TestingCardToStringShouldNotReturnEmptyString()
 {
     var card = new Card(new CardFace(), new CardSuit());
     var test = string.Empty;
     Assert.AreNotEqual(
         test,
         card.ToString(),
         string.Format("Expected {0} to not equal {1}",
         card.ToString(),
         test));
 }
        public void TestingCardToStringShouldReturnCorrectString_SevenHearts()
        {
            var card = new Card(CardFace.Seven, CardSuit.Hearts);
            var test = "7" + " " + "♥";

            Assert.AreEqual(
                test,
                card.ToString(),
                string.Format("The value {0} does not equal the expected {1}",
                card.ToString(),
                test));
        }
        public void TestingCardToStringShouldReturnCorrectString_JackDiamond()
        {
            var card = new Card(CardFace.Jack, CardSuit.Diamonds);
            var test = "J" + " " + "♦";

            Assert.AreEqual(
                test,
                card.ToString(),
                string.Format("The value {0} does not equal the expected {1}",
                card.ToString(),
                test));
        }
        public void TestingCardToStringShouldReturnCorrectString_AceSpades()
        {
            var card = new Card(CardFace.Ace, CardSuit.Spades);
            var test = "A" + " " + "♠";

            Assert.AreEqual(
                test,
                card.ToString(),
                string.Format("The value {0} does not equal the expected {1}",
                card.ToString(),
                test));
        }
Esempio n. 5
0
        public void TestToStringTwoOfDiamonds()
        {
            Card card = new Card(CardFace.Two, CardSuit.Diamonds);
            string result = "2" + this.diamond;

            Assert.AreEqual(card.ToString(), result);
        }
        public void PokerTestToStringAceHearts()
        {
            Card myCard = new Card(CardFace.Ace, CardSuit.Hearts);
            string result = myCard.ToString();

            Assert.AreEqual("A♥", result);
        }
 public void ToStringJackHearts()
 {
     Card card = new Card(CardFace.Jack, CardSuit.Hearts);
     var excpected = "J♥";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Esempio n. 8
0
        public void TestToStringAceOfClubs()
        {
            Card card = new Card(CardFace.Ace, CardSuit.Clubs);
            string result = "A" + this.club;

            Assert.AreEqual(card.ToString(), result);
        }
Esempio n. 9
0
 public void TestQueenSpadesToString()
 {
     Card card = new Card(CardFace.Queen, CardSuit.Spades);
     string expected = "Q♠";
     string result = card.ToString();
     Assert.AreEqual(expected, result);
 }
Esempio n. 10
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 ToStringTwoClubs()
 {
     Card card = new Card(CardFace.Two, CardSuit.Clubs);
     var excpected = "2♣";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Esempio n. 12
0
 public void CardToStringTestTenOfDiamonds()
 {
     Card card = new Card(CardFace.Ten, CardSuit.Diamonds);
     string expected = "10♦";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Esempio n. 13
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));
 }
Esempio n. 14
0
 public void ToStringThreeOfHearts()
 {
     Card card = new Card(CardFace.Three, CardSuit.Hearts);
     string actual = card.ToString();
     string expected = "3♥";
     Assert.AreEqual(actual, expected);
 }
Esempio n. 15
0
 public void CardToStringTestAceOfHearts()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Hearts);
     string expected = "A♥";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Esempio n. 16
0
 public void ToStringAceOfSpadesTest()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Spades);
     string actual = card.ToString();
     string expected = "A♠";
     Assert.AreEqual(actual, expected);
 }
Esempio n. 17
0
 public void ToStringJackOfClubs()
 {
     Card card = new Card(CardFace.Jack, CardSuit.Clubs);
     string actual = card.ToString();
     string expected = "J♣";
     Assert.AreEqual(actual, expected);
 }
Esempio n. 18
0
        public void TestToStringQueenOfSpades()
        {
            Card card = new Card(CardFace.Queen, CardSuit.Spades);
            string result = "Q" + this.spade;

            Assert.AreEqual(card.ToString(), result);
        }
Esempio n. 19
0
 public void TestAceHeartToString()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Hearts);
     string expected = "A♥";
     string result = card.ToString();
     Assert.AreEqual(expected, result);
 }
Esempio n. 20
0
 public void TestKingDiamondsToString()
 {
     Card card = new Card(CardFace.King, CardSuit.Spades);
     string expected = "K♠";
     string result = card.ToString();
     Assert.AreEqual(expected, result);
 }
        public void PokerTestToStringSevenDiamonds()
        {
            Card myCard = new Card(CardFace.Seven, CardSuit.Diamonds);
            string result = myCard.ToString();

            Assert.AreEqual("7♦", result);
        }
Esempio n. 22
0
        public void TestCardToString()
        {
            Card card = new Card(CardFace.Ace, CardSuit.Hearts);
            string expected = "Ace of Hearts";

            Assert.AreEqual(expected, card.ToString());
        }
        public void PokerTestToStringTwoClubs()
        {
            Card myCard = new Card(CardFace.Two, CardSuit.Clubs);
            string result = myCard.ToString();

            Assert.AreEqual("2♣", result);
        }
 public void ToStringAceSpades()
 {
     Card card = new Card(CardFace.Ace, CardSuit.Spades);
     var excpected = "A♠";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Esempio n. 25
0
 public void CardToStringTestNineOfClubs()
 {
     Card card = new Card(CardFace.Nine, CardSuit.Clubs);
     string expected = "9♣";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
Esempio n. 26
0
        public void TestToStringJackOfHearts()
        {
            Card card = new Card(CardFace.Jack, CardSuit.Hearts);
            string result = "J" + this.heart;

            Assert.AreEqual(card.ToString(), result);
        }
Esempio n. 27
0
 public void CardToStringTestTwoOfSpades()
 {
     Card card = new Card(CardFace.Two, CardSuit.Spades);
     string expected = "2♠";
     string actual = card.ToString();
     Assert.AreEqual(expected, actual);
 }
 public void ToStringTenDiamons()
 {
     Card card = new Card(CardFace.Ten, CardSuit.Diamonds);
     var excpected = "10♦";
     var actual = card.ToString();
     Assert.AreEqual(excpected, actual);
 }
Esempio n. 29
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));
 }
        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());
        }
Esempio n. 32
0
        static string CardToName(Card element)
        {
            String[] suitNames = { "Spades", "Hearts", "Clubs", "Diamonds" };
            String[] faceNames = { "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
            string   hand0     = element.ToString();

            string[] hand1    = hand0.Split(',');
            Int32[]  tempInts = Array.ConvertAll(hand1, int.Parse);
            return(faceNames[tempInts[0] - 1] + " of " + suitNames[tempInts[1] - 1]);
        }
        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());
                }
            }
        }
Esempio n. 34
0
        public void sendCard(Card message, Int32 slot)
        {
            sockets[slot].Send(encoder.GetBytes(message.ToString()));

            Thread.Sleep(100);
        }
Esempio n. 35
0
        private void btn_Table_Click(object sender, RoutedEventArgs e)
        {
            if (img_Flop1.Source == null)
            {
                logLine += "The flop: ";

                current = Game.Deck.DealCard();
                Game.TableCards.Add(current);
                logLine         += current.ToString() + ", ";
                img_Flop1.Source = new BitmapImage(new Uri(current.ImagePath(), UriKind.Relative));

                current = Game.Deck.DealCard();
                Game.TableCards.Add(current);
                logLine         += current.ToString() + ", ";
                img_Flop2.Source = new BitmapImage(new Uri(current.ImagePath(), UriKind.Relative));

                current = Game.Deck.DealCard();
                Game.TableCards.Add(current);
                logLine         += current.ToString() + ".";
                img_Flop3.Source = new BitmapImage(new Uri(current.ImagePath(), UriKind.Relative));

                txt_Log.Text += logLine + Environment.NewLine;
                logLine       = "";

                btn_Table.Content = "Turn";
            }
            else if (img_Turn.Source == null)
            {
                logLine += "The turn: ";

                current = Game.Deck.DealCard();
                Game.TableCards.Add(current);
                logLine        += current.ToString() + ".";
                img_Turn.Source = new BitmapImage(new Uri(current.ImagePath(), UriKind.Relative));

                txt_Log.Text += logLine + Environment.NewLine;
                logLine       = "";

                btn_Table.Content = "River";
            }
            else
            {
                logLine += "The river: ";

                current = Game.Deck.DealCard();
                Game.TableCards.Add(current);
                logLine         += current.ToString() + ".";
                img_River.Source = new BitmapImage(new Uri(current.ImagePath(), UriKind.Relative));

                txt_Log.Text += logLine + Environment.NewLine;
                logLine       = "";

                if (cbx_Hide.IsChecked == true)
                {
                    img_P2C1.Source = new BitmapImage(new Uri(Game.Player2.Hand[0].ImagePath(), UriKind.Relative));
                    img_P2C2.Source = new BitmapImage(new Uri(Game.Player2.Hand[1].ImagePath(), UriKind.Relative));
                }

                try
                {
                    Game.DecideWinner();

                    txt_Log.Text += Game.Player1.Name + " has " + PokerHelp.PokerCombinationToString(Game.Player1.BestHand.PokerCombination) + Environment.NewLine;
                    txt_Log.Text += Game.Player2.Name + " has " + PokerHelp.PokerCombinationToString(Game.Player2.BestHand.PokerCombination) + Environment.NewLine;

                    if (Game.Player1.Won && !Game.Player2.Won)
                    {
                        txt_Log.Text += Game.Player1.Name + " wins!" + Environment.NewLine;
                    }
                    else if (Game.Player2.Won && !Game.Player1.Won)
                    {
                        txt_Log.Text += Game.Player2.Name + " wins!" + Environment.NewLine;
                    }
                    else if (Game.Player1.Won && Game.Player2.Won)
                    {
                        txt_Log.Text += "Split pot!" + Environment.NewLine;
                    }
                    else
                    {
                        throw new Exception("Impossible winsituation");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                lbl_PointsP1.Content = Game.Player1.Points;
                lbl_PointsP2.Content = Game.Player2.Points;

                handCount++;
                lbl_HandCount.Content = handCount;

                txt_Log.Text += "--------------------------------------------------------------------------------------------------------" + Environment.NewLine;

                btn_Table.IsEnabled   = false;
                btn_Restart.IsEnabled = true;
                cbx_Hide.IsEnabled    = true;
            }
        }