コード例 #1
0
        public void TestBuildCity()
        {
            var target = new Player();

            target.incrementCities();
            target.generateGrain();
            target.generateOre();
            target.generateOre();

            target.buildCity();

            Assert.AreEqual(1, target.getHand().getOre());
            Assert.AreEqual(0, target.getHand().getGrain());
        }
コード例 #2
0
        public void TestBuildSettlement()
        {
            var target = new Player();

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

            target.buildSettlement();

            Assert.AreEqual(0, target.getHand().getBrick());
            Assert.AreEqual(0, target.getHand().getLumber());
            Assert.AreEqual(0, target.getHand().getWool());
            Assert.AreEqual(0, target.getHand().getGrain());
        }
コード例 #3
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());
        }
コード例 #4
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());
        }
コード例 #5
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");
        }
コード例 #6
0
        public void TestMustRemoveHalfWhenMoreThanSeven()
        {
            var target = new Player();
            target.incrementCities();
            target.generateGrain();
            target.generateWool();
            target.generateLumber();
            target.generateBrick();

            Assert.IsTrue(target.mustRemoveHalf());
        }
コード例 #7
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());
        }
コード例 #8
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();
        }
コード例 #9
0
 public void TestGenerateResourcesWithNoCitiesOrSettlements()
 {
     var target = new Player();
     target.generateBrick();
     target.generateGrain();
     target.generateLumber();
     target.generateOre();
     target.generateWool();
     Assert.AreEqual(0, target.getHand().getResources());
 }
コード例 #10
0
 public void TestTransferGrain()
 {
     var target = new Player();
     target.incrementSettlements();
     target.generateGrain();
     target.transferGrain(1);
 }
コード例 #11
0
        public void TestGenerateGrainWithSettlementsThrowsWhenBankHasInsufficientResources()
        {
            var target = new Player();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            target.incrementSettlements();
            Assert.AreEqual(0, target.getSettlementsRemaining());

            target.generateGrain();
            target.generateGrain();
            target.generateGrain();

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

            target.generateGrain();
        }
コード例 #12
0
 public void TestTradeWithBankWithWoolPort()
 {
     var target = new Player();
     target.incrementCities();
     target.generateGrain();
     target.generateWool();
     target.addPort(new Port("Wool", 2));
     target.tradeWithBank("wool", "grain");
     Assert.AreEqual(3, target.playerHand.getGrain());
     Assert.AreEqual(0, target.playerHand.getWool());
 }
コード例 #13
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());
 }
コード例 #14
0
        public void TestTradeWithBankForBrickThrowsWhenBankHasNone()
        {
            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.generateBrick();
            player2.incrementSettlements();
            player2.generateBrick();

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

            player1.generateGrain();

            player1.tradeWithBank("grain", "brick");
        }
コード例 #15
0
        public void TestCanBuildCity()
        {
            var target = new Player();
            Assert.IsFalse(target.canBuildCity());

            target.incrementCities();
            target.generateGrain();
            target.generateOre();
            target.generateOre();

            Assert.IsTrue(target.canBuildCity());
        }
コード例 #16
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());
        }
コード例 #17
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());
        }
コード例 #18
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]);
        }
コード例 #19
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");
        }
コード例 #20
0
 public void TestTradeGrainWithBankWithAnythingPort()
 {
     var target = new Player();
     target.incrementCities();
     target.incrementSettlements();
     target.generateGrain();
     target.addPort(new Port("Anything", 3));
     target.tradeWithBank("grain", "brick");
     Assert.AreEqual(1, target.playerHand.getBrick());
     Assert.AreEqual(0, target.playerHand.getGrain());
 }