Beispiel #1
0
        public void BuildRoadFailsIfPlayerHasNotEnoughResources()
        {
            var player = new Mock<IPlayer>();
            player.Setup(p => p.HasResources(Road.BUILD_RESOURCES)).Returns(false);
            var board = new Mock<IBoard>();
            var edge = new Mock<IEdge>();

            var command = new BuildRoadCommand(player.Object, board.Object, edge.Object);
            
            Assert.Throws<InvalidOperationException>(() => command.Execute());
            board.Verify(b => b.BuildRoad(edge.Object, player.Object), Times.Never);
            player.Verify(p => p.TakeResources(Road.BUILD_RESOURCES), Times.Never);
        }
Beispiel #2
0
        public void BuildRoadRemovesResourcesFromPlayerIfSucceeded()
        {
            var player = new Mock<IPlayer>();
            player.Setup(p => p.HasResources(Road.BUILD_RESOURCES)).Returns(true);
            var board = new Mock<IBoard>();
            var edge = new Mock<IEdge>();

            var command = new BuildRoadCommand(player.Object, board.Object, edge.Object);
            command.Execute();

            board.Verify(b => b.BuildRoad(edge.Object, player.Object));
            player.Verify(p => p.TakeResources(Road.BUILD_RESOURCES));
        }