public void ExecuteFailsIfPlayerNotEnoughResources() { var player = new Mock<IPlayer>(); var establishment = new Mock<IEstablishment>(); player.Setup(p => p.HasResources(Establishment.UPGRADE_RESOURCES)).Returns(false); var command = new UpgradeEstablishmentCommand(player.Object, establishment.Object); Assert.Throws<InvalidOperationException>(() => command.Execute()); }
public void ExecuteTest() { var player = new Mock<IPlayer>(); var establishment = new Mock<IEstablishment>(); player.Setup(p => p.HasResources(Establishment.UPGRADE_RESOURCES)).Returns(true); var command = new UpgradeEstablishmentCommand(player.Object, establishment.Object); command.Execute(); establishment.Verify(e => e.Upgrade(), Times.Once); player.Verify(p => p.TakeResources(Establishment.UPGRADE_RESOURCES), Times.Once); }