Example #1
0
        public void UpdgradeFailsIfLevelAlreadyCity()
        {
            var player = new Mock<IPlayer>();
            var vertex = new Mock<IVertex>();

            var establisment = new Establishment(player.Object, vertex.Object);

            establisment.Upgrade();
            Assert.Throws<InvalidOperationException>(() => establisment.Upgrade());
        }
Example #2
0
        public void UpgradeSetsLevelToCity()
        {
            var player = new Mock<IPlayer>();
            var vertex = new Mock<IVertex>();
            var establisment = new Establishment(player.Object, vertex.Object);

            establisment.Upgrade();

            Assert.Equal(EstablishmentLevel.City, establisment.Level);
        }
Example #3
0
        public void HarvestUpgradedEstablismentAdds2ResourcesToPlayer()
        {
            var player = new Mock<IPlayer>();
            player.Setup(p => p.HasResources(Establishment.UPGRADE_RESOURCES)).Returns(true);

            var vertex = new Mock<IVertex>();
            var tileMock = new Mock<ITile>();
            tileMock.Setup(t => t.Rawmaterial).Returns(MaterialType.Grain);
            tileMock.Setup(t => t.Farm()).Returns(new Mock<IRawMaterial>().Object);

            var tile = tileMock.Object;
            vertex.Setup(v => v.IsAdjacentTo(tile)).Returns(true);

            var establisment = new Establishment(player.Object, vertex.Object);
            establisment.Upgrade();
            establisment.Harvest(tile);

            player.Verify(p => p.AddResources(It.IsAny<IRawMaterial>()), Times.Exactly(2));
        }