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."); }
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."); }
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."); }
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."); }