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