コード例 #1
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.");
        }
コード例 #2
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.");
        }