Exemplo n.º 1
0
        public void ExecuteTest()
        {
            var player = new Mock<IPlayer>();
            var board = new Mock<IBoard>();
            var vertex = new Mock<IVertex>();

            player.Setup(p => p.HasResources(Establishment.BUILD_RESOURCES)).Returns(true);

            var command = new BuildEstablishmentCommand(player.Object, board.Object, vertex.Object);
            command.Execute();

            board.Verify(b => b.BuildEstablishment(vertex.Object, player.Object));
            player.Verify(p => p.TakeResources(Establishment.BUILD_RESOURCES));
        }
Exemplo n.º 2
0
        public void ExecuteFailsIfPlayerNotEnoughtResources()
        {
            var player = new Mock<IPlayer>();
            var board = new Mock<IBoard>();
            var vertex = new Mock<IVertex>();

            player.Setup(p => p.HasResources(Establishment.BUILD_RESOURCES)).Returns(false);

            var command = new BuildEstablishmentCommand(player.Object, board.Object, vertex.Object);
            Assert.Throws<InvalidOperationException>(() => command.Execute());

            board.Verify(b => b.BuildEstablishment(vertex.Object, player.Object), Times.Never);
            player.Verify(p => p.TakeResources(Establishment.BUILD_RESOURCES), Times.Never);
        }