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());
        }
        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");
        }
        public void TestMustRemoveHalfWhenMoreThanSeven()
        {
            var target = new Player();
            target.incrementCities();
            target.generateGrain();
            target.generateWool();
            target.generateLumber();
            target.generateBrick();

            Assert.IsTrue(target.mustRemoveHalf());
        }
        public void TestmakeTradeThrowsWhenPlayerCannotMakeTrade()
        {
            var player1 = new Player();
            var player2 = new Player();
            player1.incrementCities();
            player1.generateOre();
            player2.incrementCities();
            player2.generateBrick();
            int[] player1Hand = new int[] {2, 0, 0, 0, 0};
            int[] threeBricks = new int[] {0, 0, 0, 0, 3};
            player1.proposeTrade(player2, player1Hand, threeBricks);

            // should throw because player2 only has 2 bricks
            player2.makeTrade();
        }
 public void TestMakeTrade()
 {
     var player1 = new Player();
     var player2 = new Player();
     player1.incrementCities();
     player1.generateOre();
     player2.incrementCities();
     player2.generateBrick();
     int[] player1Hand = new int[] {2, 0, 0, 0, 0};
     int[] player2Hand = new int[] {0, 0, 0, 0, 2};
     player1.proposeTrade(player2, player1Hand, player2Hand);
     player2.makeTrade();
 }
        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");
        }
        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());
        }
 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());
 }
        public void TestGenerateBrickWithSettlementsThrowsWhenBankHasInsufficientResources()
        {
            var target = new Player();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            Assert.AreEqual(0, target.getSettlementsRemaining());

            target.generateBrick();
            target.generateBrick();
            target.generateBrick();

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

            target.generateBrick();
        }
 public void TestGenerateResourcesWithNoCitiesOrSettlements()
 {
     var target = new Player();
     target.generateBrick();
     target.generateGrain();
     target.generateLumber();
     target.generateOre();
     target.generateWool();
     Assert.AreEqual(0, target.getHand().getResources());
 }
 public void TestTransferBrick()
 {
     var target = new Player();
     target.incrementSettlements();
     target.generateBrick();
     target.transferBrick(1);
 }
 public void TestTradeWithBankWithGrainPort()
 {
     var target = new Player();
     target.incrementCities();
     target.generateBrick();
     target.generateGrain();
     target.addPort(new Port("Grain", 2));
     target.tradeWithBank("grain", "brick");
     Assert.AreEqual(3, target.playerHand.getBrick());
     Assert.AreEqual(0, target.playerHand.getGrain());
 }
 public void TestTradeWithBankWithBrickPort()
 {
     var target = new Player();
     target.incrementCities();
     target.generateLumber();
     target.generateBrick();
     target.addPort(new Port("Brick", 2));
     target.tradeWithBank("brick", "lumber");
     Assert.AreEqual(3, target.playerHand.getLumber());
     Assert.AreEqual(0, target.playerHand.getBrick());
 }
        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());
        }
        public void TestGetRoadsPlayed()
        {
            var target = new Player();
            target.incrementCities();
            target.generateBrick();
            target.generateLumber();

            target.buildRoad();
            target.buildRoad();

            Assert.AreEqual(2, target.getRoadsPlayed());
        }
        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());
        }
        public void TestGetSettlementLocations()
        {
            var target = new Player();
            target.incrementCities();
            target.generateGrain();
            target.generateWool();
            target.generateLumber();
            target.generateBrick();

            target.addSettlement(new Point(4, 4));
            List<Point> settlements = target.getSettlementLocations();
            Assert.AreEqual(new Point(4, 4), settlements[0]);
        }
        public void TestTradeForBrickAtPortThrowsWhenBankHasNone()
        {
            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.generateBrick();
            player2.generateBrick();
            player2.generateBrick();
            Assert.AreEqual(0, world.bank.getBrickRemaining());

            player1.generateGrain();
            player1.generateGrain();
            player1.generateGrain();
            player1.tradeAtPort(3, "brick", "grain");
        }
        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());
        }