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

            Assert.IsTrue(target.mustRemoveHalf());
        }
예제 #4
0
        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();
        }
예제 #5
0
 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();
 }
예제 #6
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");
        }
예제 #7
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());
        }
예제 #8
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());
 }
예제 #9
0
        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();
        }
예제 #10
0
 public void TestGenerateResourcesWithNoCitiesOrSettlements()
 {
     var target = new Player();
     target.generateBrick();
     target.generateGrain();
     target.generateLumber();
     target.generateOre();
     target.generateWool();
     Assert.AreEqual(0, target.getHand().getResources());
 }
예제 #11
0
 public void TestTransferBrick()
 {
     var target = new Player();
     target.incrementSettlements();
     target.generateBrick();
     target.transferBrick(1);
 }
예제 #12
0
 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());
 }
예제 #13
0
 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());
 }
예제 #14
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());
        }
예제 #15
0
        public void TestGetRoadsPlayed()
        {
            var target = new Player();
            target.incrementCities();
            target.generateBrick();
            target.generateLumber();

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

            Assert.AreEqual(2, target.getRoadsPlayed());
        }
예제 #16
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());
        }
예제 #17
0
        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]);
        }
예제 #18
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");
        }
예제 #19
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());
        }