Пример #1
0
        public void TestEndTurn()
        {
            var target = new World(3, 0, null);

            //testing first round
            Assert.AreEqual("Bob", target.currentPlayer.getName());
            target.endTurn();
            Assert.AreEqual("Joe", target.currentPlayer.getName());
            target.endTurn();
            Assert.AreEqual("Computer", target.currentPlayer.getName());

            // testing second round
            target.endTurn();
            Assert.AreEqual("Computer", target.currentPlayer.getName());
            target.endTurn();
            Assert.AreEqual("Joe", target.currentPlayer.getName());
            target.endTurn();
            Assert.AreEqual("Bob", target.currentPlayer.getName());
            target.endTurn();

            //testing third round
            //player has not rolled
            Assert.AreEqual("Bob", target.currentPlayer.getName());
            target.endTurn();
            Assert.AreEqual("Bob", target.currentPlayer.getName());
            //playerhas rolled
            target.rollDice();
            target.endTurn();
            Assert.AreEqual("Joe", target.currentPlayer.getName());
            target.rollDice();
            target.endTurn();
            Assert.AreEqual("Computer", target.currentPlayer.getName());
            target.rollDice();
            target.endTurn();
            Assert.AreEqual("Bob", target.currentPlayer.getName());
        }
Пример #2
0
 public void testRollDice()
 {
     World w = new World(3, 0, null);
     Player player1 = new Player("Meeeeee!", Color.HotPink, w);
     w.addPlayer(player1);
     w.setCurrentPlayer(player1.getName());
     //test without completeing early rounds
     w.rollDice();
     Assert.IsFalse(w.currentPlayer.hasRolled);
     //test extra roll without completeing early rounds
     w.rollDice();
     Assert.IsFalse(w.currentPlayer.hasRolled);
     w.numOfCompletedRounds = 5;
     //test first roll after early rounds
     w.rollDice();
     Assert.IsTrue(w.currentPlayer.hasRolled);
     //test extra roll after early rounds
     w.rollDice();
     Assert.IsTrue(w.currentPlayer.hasRolled);
 }
Пример #3
0
 public void TestRounds()
 {
     World w = new World(3, 0, null);
     int rounds = 0;
     for (int i = 0; i < 9; i++)
     {
         w.rollDice();
         w.endTurn();
         if (i%3 == 0)
         {
             rounds++;
         }
     }
     Assert.AreEqual(rounds, w.getNumberOfRoundsCompleted());
 }
Пример #4
0
 public void testGetRollNumber()
 {
     World w = new World(3, 0, null);
     Player player1 = new Player("Meeeeee!", Color.HotPink, w);
     w.addPlayer(player1);
     w.setCurrentPlayer(player1.getName());
     //test getting roll number without rolling
     Assert.AreEqual(0, w.getRollNumber());
     w.numOfCompletedRounds = 5;
     //test getting roll number after rolling
     w.rollDice();
     Assert.IsTrue(w.getRollNumber() < 13 && w.getRollNumber() > 1);
 }