Exemplo n.º 1
0
        public void TestBuildRoad()
        {
            var target = new Player();

            target.incrementSettlements();
            target.generateBrick();
            target.generateLumber();

            target.buildRoad();

            Assert.AreEqual(0, target.getHand().getBrick());
            Assert.AreEqual(0, target.getHand().getLumber());
        }
Exemplo n.º 2
0
        public void TestTradeForGrainAtPortThrowsWhenBankHasNone()
        {
            World world = new World();
            var player1 = new Player("Bob", Color.Red, world);
            var player2 = new Player("Jim", Color.Blue, world);

            player1.incrementSettlements();

            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementSettlements();

            player1.generateGrain();
            player2.generateGrain();
            player2.generateGrain();
            Assert.AreEqual(0, world.bank.getGrainRemaining());

            player1.generateOre();
            player1.generateOre();
            player1.generateOre();
            player1.tradeAtPort(3, "grain", "ore");
        }
Exemplo n.º 3
0
        public void TestTradeForDevCardThrowsWhenBankHasNoDevCards()
        {
            var target = new Player();

            target.incrementCities();
            target.incrementCities();
            target.incrementSettlements();

            for (int i = 0; i < 5; i++)
            {
                target.generateGrain();
                target.generateOre();
                target.generateWool();

                for (int j = 0; j < 5; j++)
                {
                    target.tradeForDevCard();
                }
            }

            target.generateGrain();
            target.generateOre();
            target.generateWool();

            // should generate an exception
            target.tradeForDevCard();
        }
Exemplo n.º 4
0
        public void TestTradeForDevCard()
        {
            var target = new Player();

            target.incrementSettlements();
            target.generateWool();
            target.generateGrain();
            target.generateOre();

            target.tradeForDevCard();
            Assert.AreEqual(0, target.getHand().getResources());
            Assert.AreEqual(1, target.getHand().getDevCardCount());
        }
Exemplo n.º 5
0
 public void TestTradeBrickWithBankWithAnythingPort()
 {
     var target = new Player();
     target.incrementCities();
     target.incrementSettlements();
     target.generateBrick();
     target.addPort(new Port("Anything", 3));
     target.tradeWithBank("brick", "lumber");
     Assert.AreEqual(1, target.playerHand.getLumber());
     Assert.AreEqual(0, target.playerHand.getBrick());
 }
Exemplo n.º 6
0
        public void TestTradeAtPort()
        {
            var target = new Player();

            target.incrementCities();
            target.incrementSettlements();

            target.generateBrick();
            target.generateGrain();
            target.generateLumber();
            target.generateOre();
            target.generateWool();

            target.tradeAtPort(3, "grain", "brick");
            target.tradeAtPort(3, "lumber", "grain");
            target.tradeAtPort(3, "ore", "lumber");
            target.tradeAtPort(3, "wool", "ore");
            target.tradeAtPort(3, "brick", "wool");

            Assert.AreEqual(1, target.getHand().getGrain());
            Assert.AreEqual(1, target.getHand().getLumber());
            Assert.AreEqual(1, target.getHand().getOre());
            Assert.AreEqual(1, target.getHand().getWool());
            Assert.AreEqual(1, target.getHand().getBrick());
        }
Exemplo n.º 7
0
        public void TestRob()
        {
            var target = new Player();
            target.incrementSettlements();

            target.generateLumber();
            Assert.AreEqual("lumber", target.rob());
            Assert.AreEqual(0, target.playerHand.getLumber());

            target.generateBrick();
            Assert.AreEqual("brick", target.rob());
            Assert.AreEqual(0, target.playerHand.getBrick());

            target.generateGrain();
            Assert.AreEqual("grain", target.rob());
            Assert.AreEqual(0, target.playerHand.getGrain());

            target.generateWool();
            Assert.AreEqual("wool", target.rob());
            Assert.AreEqual(0, target.playerHand.getWool());

            target.generateOre();
            Assert.AreEqual("ore", target.rob());
            Assert.AreEqual(0, target.playerHand.getOre());
        }
Exemplo n.º 8
0
        public void TestPickString()
        {
            var target = new Player();
            target.incrementSettlements();
            List<string> resources = new List<string>();

            target.generateLumber();
            resources.Add("lumber");
            Assert.AreEqual("lumber", target.pickString(resources));
            Assert.AreEqual(0, target.playerHand.getLumber());
            resources.Remove("lumber");

            target.generateBrick();
            resources.Add("brick");
            Assert.AreEqual("brick", target.pickString(resources));
            Assert.AreEqual(0, target.playerHand.getBrick());
            resources.Remove("brick");

            target.generateGrain();
            resources.Add("grain");
            Assert.AreEqual("grain", target.pickString(resources));
            Assert.AreEqual(0, target.playerHand.getGrain());
            resources.Remove("grain");

            target.generateWool();
            resources.Add("wool");
            Assert.AreEqual("wool", target.pickString(resources));
            Assert.AreEqual(0, target.playerHand.getWool());
            resources.Remove("wool");

            target.generateOre();
            resources.Add("ore");
            Assert.AreEqual("ore", target.pickString(resources));
            Assert.AreEqual(0, target.playerHand.getOre());
            resources.Remove("ore");
        }
Exemplo n.º 9
0
        public void TestGenerateWoolWithSettlementsThrowsWhenBankHasInsufficientResources()
        {
            var target = new Player();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            Assert.AreEqual(0, target.getSettlementsRemaining());

            target.generateWool();
            target.generateWool();
            target.generateWool();

            Assert.AreEqual(15, target.getHand().getWool());

            target.generateWool();
        }
Exemplo n.º 10
0
 public void TestTransferWool()
 {
     var target = new Player();
     target.incrementSettlements();
     target.generateWool();
     target.transferWool(1);
 }
Exemplo n.º 11
0
        public void TestGenerateResourcesWithOnlySettlements()
        {
            var target = new Player();
            target.incrementSettlements();
            target.incrementSettlements();
            Assert.AreEqual(3, target.getSettlementsRemaining());

            target.generateBrick();
            target.generateGrain();
            target.generateLumber();
            target.generateOre();
            target.generateWool();

            Assert.AreEqual(2, target.getHand().getBrick());
            Assert.AreEqual(2, target.getHand().getGrain());
            Assert.AreEqual(2, target.getHand().getLumber());
            Assert.AreEqual(2, target.getHand().getOre());
            Assert.AreEqual(2, target.getHand().getWool());
        }
Exemplo n.º 12
0
 public void TestTradeWoolWithBankWithAnythingPort()
 {
     var target = new Player();
     target.incrementCities();
     target.incrementSettlements();
     target.generateWool();
     target.addPort(new Port("Anything", 3));
     target.tradeWithBank("wool", "grain");
     Assert.AreEqual(1, target.playerHand.getGrain());
     Assert.AreEqual(0, target.playerHand.getWool());
 }
Exemplo n.º 13
0
        public void TestTradeWithBankForWoolThrowsWhenBankHasNone()
        {
            World world = new World();
            var player1 = new Player("Bob", Color.Red, world);
            var player2 = new Player("Jim", Color.Blue, world);

            player1.incrementCities();
            player1.incrementCities();

            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementSettlements();

            player2.generateWool();
            player2.incrementSettlements();
            player2.generateWool();

            Assert.AreEqual(0, world.bank.getWoolRemaining());

            player1.generateBrick();

            player1.tradeWithBank("brick", "wool");
        }
Exemplo n.º 14
0
        public void TestTradeWithBankForOreThrowsWhenBankHasNone()
        {
            World world = new World();
            var player1 = new Player("Bob", Color.Red, world);
            var player2 = new Player("Jim", Color.Blue, world);

            player1.incrementCities();
            player1.incrementCities();

            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementSettlements();

            player2.generateOre();
            player2.incrementSettlements();
            player2.generateOre();

            Assert.AreEqual(0, world.bank.getOreRemaining());

            player1.generateLumber();

            player1.tradeWithBank("lumber", "ore");
        }
Exemplo n.º 15
0
        public void TestCanBuildSettlement()
        {
            var target = new Player();
            Assert.IsFalse(target.canBuildSettlement());

            target.incrementSettlements();
            target.generateBrick();
            target.generateLumber();
            target.generateGrain();
            target.generateWool();

            Assert.IsTrue(target.canBuildSettlement());
        }
Exemplo n.º 16
0
        public void TestTradeForWoolAtPortThrowsWhenBankHasNone()
        {
            World world = new World();
            var player1 = new Player("Bob", Color.Red, world);
            var player2 = new Player("Jim", Color.Blue, world);

            player1.incrementSettlements();

            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementCities();
            player2.incrementSettlements();

            player1.generateWool();
            player2.generateWool();
            player2.generateWool();
            Assert.AreEqual(0, world.bank.getWoolRemaining());

            player1.generateLumber();
            player1.generateLumber();
            player1.generateLumber();
            player1.tradeAtPort(3, "wool", "lumber");
        }