Example #1
0
        public void DifferentResourceHarborGetsIgnored()
        {
            var board = new Mock<IBoard>();
            var player = new Mock<IPlayer>();
            var achievements = new IAchievement[0];

            var bank = new Bank(board.Object, achievements);
            var harbor = new Mock<IHarbor>();
            harbor.Setup(h => h.Discount).Returns(MaterialType.Wool);
            board.Setup(b => b.GetHarbors(player.Object)).Returns(new IHarbor[] { harbor.Object });

            MaterialType[] result = bank.GetInvestmentCost(MaterialType.Grain, player.Object);
            MaterialType[] expected = { MaterialType.Grain, MaterialType.Grain, MaterialType.Grain, MaterialType.Grain };
            Assert.Equal(expected, result);
        }
Example #2
0
        public void GetInvestmentCostUsesCheapestHarbor()
        {
            var board = new Mock<IBoard>();
            var player = new Mock<IPlayer>();
            var achievements = new IAchievement[0];
            var bank = new Bank(board.Object, achievements);

            var unsourcedHarbor = new Mock<IHarbor>();
            unsourcedHarbor.Setup(h => h.Discount).Returns(MaterialType.Unsourced);
            var resourceHarbor = new Mock<IHarbor>();
            resourceHarbor.Setup(h => h.Discount).Returns(MaterialType.Grain);
            board.Setup(b => b.GetHarbors(player.Object)).Returns(new IHarbor[] { unsourcedHarbor.Object, resourceHarbor.Object });

            MaterialType[] result = bank.GetInvestmentCost(MaterialType.Grain, player.Object);
            MaterialType[] expected = { MaterialType.Grain, MaterialType.Grain };
            Assert.Equal(expected, result);
        }
Example #3
0
        public void GetInvestmentFailsOnInvalidResource(MaterialType material)
        {
            var board = new Mock<IBoard>();
            var player = new Mock<IPlayer>();
            var achievements = new IAchievement[0];
            var bank = new Bank(board.Object, achievements);

            Assert.Throws<ArgumentException>(() => bank.GetInvestmentCost(material, player.Object));
        }
Example #4
0
        public void GetInvestmentCostDefaultReturns4()
        {
            var board = new Mock<IBoard>();
            var player = new Mock<IPlayer>();
            var achievements = new IAchievement[0];
            var bank = new Bank(board.Object, achievements);

            MaterialType[] result = bank.GetInvestmentCost(MaterialType.Grain, player.Object);
            MaterialType[] expected = { MaterialType.Grain, MaterialType.Grain, MaterialType.Grain, MaterialType.Grain };
            Assert.Equal(expected, result);
        }
Example #5
0
        public void GetInvestmentCostNeedsPlayer()
        {
            var board = new Mock<IBoard>();
            var achievements = new IAchievement[0];
            var bank = new Bank(board.Object, achievements);

            Assert.Throws<ArgumentNullException>(() => bank.GetInvestmentCost(MaterialType.Grain, null));
        }