예제 #1
0
        public void HealMethod_AppropriatelyAltersCurrentHealth()
        {
            const int damage = FighterHealth - 1;

            _fighter.PhysicalDamage(damage);
            var ret = _fighter.Heal(damage - 2);

            Assert.AreEqual(FighterHealth - 2, _fighter.CurrentHealth);
            Assert.AreEqual(FighterHealth, _fighter.MaxHealth);

            Assert.AreEqual(2, ret);
        }
        public void MessageDisplayed_OnFighterHealed([Values(5, 10, 25)] int healAmount, [Values] bool shouldTryToOverheal)
        {
            //arrange
            _humanPlayer1.SetHealth(100, shouldTryToOverheal ? 99 : 1);
            _humanPlayer1.SetMove(_doNothingMove);
            _humanPlayer2.SetMove(_doNothingMove);

            _humanTeam.SetDeathsOnRoundEndEvent();

            _enemyPlayer1.SetMove(_doNothingMove);
            _enemyPlayer2.SetMove(_doNothingMove);

            _humanPlayer1.TurnEnded += delegate { _humanPlayer1.Heal(healAmount); };

            //Act
            _battleManager.Battle(_humanTeam, _enemyTeam);

            //Assert
            MockOutputMessage[] outputs = _output.GetOutputs();

            int               expectedHealAmount = shouldTryToOverheal ? 1 : healAmount;
            string            expectedMessage    = $"{_humanPlayer1.DisplayName} was healed for {expectedHealAmount} HP!\n";
            MockOutputMessage output             = outputs.FirstOrDefault(o => o.Message == expectedMessage);

            Assert.NotNull(output);
        }