Пример #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 TestGenerateResourcesWithRequiredNumberOfRounds()
 {
     World w = new World(3, 0, null);
     int rounds = 0;
     for (int i = 0; i < 9; i++)
     {
         w.endTurn();
         if (i%3 == 0)
         {
             rounds++;
         }
     }
     Assert.AreEqual(rounds - 1, w.getNumberOfRoundsCompleted());
 }
Пример #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 TestLargestArmyGetsSetWhenArmyIsLarger()
        {
            var target = new World(3, 0, null);
            target.endTurn();

            // player 2
            for (int i = 0; i < 3; i++)
            {
                target.currentPlayer.playerHand.incrementKnightsPlayed();
            }

            target.endTurn();

            Assert.AreEqual(3, target.largestArmySize);
            Assert.AreEqual(1, target.largestArmyOwnerIndex);
            Assert.AreEqual(2, target.players[target.largestArmyOwnerIndex].getPoints());
            Assert.IsTrue(target.players[target.largestArmyOwnerIndex].hasLargestArmy);

            // player 3
            for (int i = 0; i < 4; i++)
            {
                target.currentPlayer.playerHand.incrementKnightsPlayed();
            }
            target.endTurn();

            Assert.AreEqual(4, target.largestArmySize);
            Assert.AreEqual(2, target.largestArmyOwnerIndex);
            Assert.AreEqual(0, target.players[target.largestArmyOwnerIndex - 1].getPoints());
            Assert.IsFalse(target.players[target.largestArmyOwnerIndex - 1].hasLargestArmy);
            Assert.AreEqual(2, target.players[target.largestArmyOwnerIndex].getPoints());
            Assert.IsTrue(target.players[target.largestArmyOwnerIndex].hasLargestArmy);
        }
Пример #5
0
        public void TestLargestArmyDoesNotGetSetIfNoOneHasLargestArmy()
        {
            var target = new World(3, 0, null);

            target.currentPlayer.playerHand.incrementKnightsPlayed();
            target.currentPlayer.playerHand.incrementKnightsPlayed();
            target.endTurn();

            Assert.AreEqual(0, target.largestArmySize);
            Assert.AreEqual(-1, target.largestArmyOwnerIndex);
        }
Пример #6
0
 public void TestIsFirstFewTurnsPhase()
 {
     var target = new World(2, 1, null);
     Assert.IsTrue(target.isFirstFewTurnsPhase());
     target.endTurn();
     target.endTurn();
     target.endTurn();
     Assert.IsTrue(target.isFirstFewTurnsPhase());
     target.endTurn();
     target.endTurn();
     target.endTurn();
     Assert.IsFalse(target.isFirstFewTurnsPhase());
 }