예제 #1
0
파일: UnitTest2.cs 프로젝트: djvorr/SSE
        public void TestCPUPick()
        {
            List<Card> cards = new List<Card>();
            Card c = new Card('H', "10");
            cards.Add(c);
            Card c1 = new Card('C', "K");
            cards.Add(c1);
            Card c2 = new Card('D', "K");
            cards.Add(c2);
            Card c3 = new Card('S', "9");
            cards.Add(c3);

            Hand hand = new Hand(cards);
            CPU cpu = new CPU();
            cpu.hand = hand;

            Assert.AreEqual(cpu.pickCard().compare(c), 0, "Pick() not default to index 0.");

            Assert.AreEqual(cpu.pickCard(new Card('H', "9")), c, "Pick(higher) not correct for H9.");
            Assert.AreEqual(cpu.pickCard(new Card('C', "J")), c1, "Pick(higher) not correct for CJ.");
            Assert.AreEqual(cpu.pickCard(new Card('S', "K")), c3, "Pick(higher) not correct for SK.");
            Assert.AreEqual(cpu.pickCard(new Card('C', "A")), c3, "Pick(higher) not correct for CA.");

            cpu.hand.removeCard(c3);
            cpu.hand.removeCard(c2);

            Assert.AreEqual(cpu.pickCard(new Card('D', "9")), c, "Pick(higher) not correct for D9.");
        }
예제 #2
0
파일: UnitTest1.cs 프로젝트: djvorr/SSE
        public void TestHand()
        {
            List<Card> cards = new List<Card>();
            Card c = new Card('H', "10");
            cards.Add(c);
            Card c1 = new Card('A', "9");
            cards.Add(c1);
            Card c2 = new Card('D', "K");
            cards.Add(c2);
            Hand hand = new Hand(cards);

            //Test to make sure all cards made it into the hand.
            Assert.IsTrue(hand.getCards().Contains(c), "Hand.GetCards.Contains failed for first card.");
            Assert.IsTrue(hand.getCards().Contains(c1), "Hand.GetCards.Contains failed for second card.");
            Assert.IsTrue(hand.getCards().Contains(c2), "Hand.GetCards.Contains failed for third card.");

            //Test to make sure a removed item no longer exists, but the others still do.
            hand.removeCard(c);
            Assert.IsTrue(hand.getCards().Contains(c) == false, "Hand.GetCards.Contains failed for removed card.");
            Assert.IsTrue(hand.getCards().Contains(c1), "Hand.GetCards.Contains failed for first remaining card.");
            Assert.IsTrue(hand.getCards().Contains(c2), "Hand.GetCards.Contains failed for second remaining card.");
        }
예제 #3
0
파일: Board.cs 프로젝트: djvorr/SSE
        /// <summary>
        /// Draws the card suit and face on the respective button.
        /// </summary>
        /// <param name="h"></param>
        public void drawHand(Hand h)
        {
            List<Card> cards = h.getCards();

            //button1.Text = "derp";
            /*
            for (int i = 0; i < hand.Count; i++)
            {
                if (i < cards.Count)
                {
                    ((Button)hand[i]).Text = cards[i].getSuit() + cards[i].getFace();
                    ((Button)hand[i]).Enabled = true;
                }
                else
                {
                    ((Button)hand[i]).Text = "";
                    ((Button)hand[i]).Enabled = false;
                }
            }*/

            int i = 0;

            foreach(Control c in this.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    if (i < h.getCards().Count)
                    {
                        if (cards[i].getFace().Length > 0)
                        {
                            ((Button)c).Text = cards[i].getSuit() + cards[i].getFace();
                            i++;
                        }
                    }
                    else
                        ((Button)c).Text = "";
                }
            }
        }
예제 #4
0
파일: UnitTest1.cs 프로젝트: djvorr/SSE
        public void TestSeat()
        {
            List<Card> cards = new List<Card>();
            cards.Add(new Card('H', "10"));
            cards.Add(new Card('A', "9"));
            cards.Add(new Card('D', "K"));
            Hand hand = new Hand(cards);

            List<Card> cards2 = new List<Card>();
            cards2.Add(new Card('H', "9"));
            cards2.Add(new Card('A', "K"));
            cards2.Add(new Card('D', "9"));
            Hand hand2 = new Hand(cards);

            Player player = new Player();
            player.hand = hand;

            CPU cpu = new CPU();
            cpu.hand = hand2;

            //Test to ensure wrong hands were not assigned.
            Assert.IsFalse(player.getHand() == hand2, "Player.GetHand returned invalid hand.");
            Assert.IsFalse(cpu.getHand() == hand, "CPU.GetHand returned invalid hand.");

            //Test to ensure correct hands were assigned.
            Assert.IsTrue(player.getHand() == hand, "Player.GetHand failed return hand.");
            Assert.IsTrue(cpu.getHand() == hand2, "CPU.GetHand failed return hand.");
        }
예제 #5
0
파일: UnitTest1.cs 프로젝트: djvorr/SSE
        public void TestTable()
        {
            List<Card> cards = new List<Card>();
            cards.Add(new Card('H', "10"));
            cards.Add(new Card('A', "9"));
            cards.Add(new Card('D', "K"));
            Hand hand = new Hand(cards);

            List<Card> cards2 = new List<Card>();
            cards2.Add(new Card('H', "9"));
            cards2.Add(new Card('A', "K"));
            cards2.Add(new Card('D', "9"));
            Hand hand2 = new Hand(cards);

            List<Seat> seats = new List<Seat>();
            seats.Add(new Player());
            CPU cpu = new CPU();
            cpu.hand = hand;
            seats.Add(cpu);

            Table table = new Table();
            table.setOrder(seats);

            List<Hand> hands = new List<Hand>();
            hands.Add(hand2);
            table.setHands(hands);

            //Try to get the current turn value, the person who should go next
            Assert.IsTrue(table.getTurn() == 0, "Table.GetTurn failed");
            Assert.IsTrue(table.nextTurn().GetType() == (new Player()).GetType(), "Table.NextTurn failed");

            //Test an increament of turn counter.
            table.turn += 1;
            Assert.IsTrue(table.getTurn() == 1, "Table.GetTurn error with incremented.");

            //Try and get the CPU hand just for fun.
            Assert.IsTrue(table.nextTurn().getHand().Find('H', "10"), "Table.GetTurn error getting CPU hand.");

            //Test to make sure the hand was added to the table
            Assert.IsTrue(table.getHands().Contains(hand2), "Error adding a hand to the table.");
        }
예제 #6
0
파일: UnitTest2.cs 프로젝트: djvorr/SSE
        public void TestDrawHand()
        {
            List<Card> cards = new List<Card>();
            Card c = new Card('H', "10");
            cards.Add(c);
            Card c1 = new Card('C', "K");
            cards.Add(c1);
            Card c2 = new Card('D', "K");
            cards.Add(c2);
            Card c3 = new Card('S', "9");
            cards.Add(c3);

            Hand hand = new Hand(cards);
            Board board = new Board();
            board.clearButtons();
            board.drawHand(hand);

            List<Button> buttons = board.getHand();

            Assert.IsTrue(buttons[0].Text.Length > 0, "Button 0 card not loaded.");
            Assert.IsTrue(buttons[1].Text.Length > 0, "Button 1 card not loaded.");
            Assert.IsTrue(buttons[2].Text.Length > 0, "Button 2 card not loaded.");
            Assert.IsTrue(buttons[3].Text.Length > 0, "Button 3 card not loaded.");
            Assert.IsTrue(buttons[4].Text.Length == 0, "Button 4 card loaded.");
            Assert.IsTrue(buttons[5].Text.Length == 0, "Button 5 card loaded.");

            cards.Add(c3);
            cards.Add(c3);

            hand = new Hand(cards);
            board.drawHand(hand);
            buttons = board.getHand();

            Assert.IsTrue(buttons[5].Text.Length > 0, "Button 5 card not loaded.");

            cards.Clear();

            hand = new Hand(cards);
            board.drawHand(hand);
            buttons = board.getHand();

            Assert.IsTrue(buttons[0].Text.Length == 0, "Button 0 wrongly loaded.");
            Assert.IsTrue(buttons[5].Text.Length == 0, "Button 5 wrongly loaded.");
        }
예제 #7
0
파일: UnitTest2.cs 프로젝트: djvorr/SSE
        public void TestTableMore()
        {
            List<Seat> seats = new List<Seat>();
            Table table = new Table();

            table.turn = 0;
            seats.Clear();

            List<Card> cards = new List<Card>();

            Hand hand = new Hand(cards);
            Player p = new Player();
            p.hand = hand;
            CPU cpu1 = new CPU();
            cpu1.hand = hand;
            CPU cpu2 = new CPU();
            cpu2.hand = hand;
            CPU cpu3 = new CPU();
            cpu3.hand = hand;

            seats.Add(p);
            seats.Add(cpu1);
            seats.Add(cpu2);
            seats.Add(cpu3);
            table.setOrder(seats);

            Seat s = table.takeTurn();
            Assert.AreEqual(table.turn, 1, "TakeTurn not working for turn = 1.");
            Assert.AreEqual(s.GetType(), typeof(Player), "TakeTurn not working for turn = 1 type.");
            //Assert.AreEqual(s.GetType(), table.getLast().GetType(), "GetLast not equal for turn = 1.");

            table.turn = 3;

            s = table.takeTurn();
            Assert.AreEqual(table.turn, 0, "TakeTurn not working for turn = 0.");
            Assert.AreEqual(s.GetType(), typeof(CPU), "TakeTurn not working for turn = 0 type.");
            //Assert.AreEqual(s.GetType(), table.getLast().GetType(), "GetLast not equal for turn = 0.");

            s = table.takeTurn();
            Assert.AreEqual(table.turn, 1, "TakeTurn not working for turn = 1.2.");
            Assert.AreEqual(s.GetType(), typeof(Player), "TakeTurn not working for turn = 1.2 type.");
            //Assert.AreEqual(s.GetType(), table.getLast().GetType(), "GetLast not equal for turn = 1.2.");

            Assert.IsTrue(table.noMoreTurns(), "Detected at least one card.");
        }