From 276bd5eebf8fa6b4793fff5fe406323aa6fbcbc5 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 1 Mar 2023 13:02:50 +0300 Subject: [PATCH] vcmi: fix healing effect tests --- test/spells/effects/HealTest.cpp | 14 ++++++++++++++ test/spells/effects/SacrificeTest.cpp | 3 +++ 2 files changed, 17 insertions(+) diff --git a/test/spells/effects/HealTest.cpp b/test/spells/effects/HealTest.cpp index 46abd201f..a32f2c918 100644 --- a/test/spells/effects/HealTest.cpp +++ b/test/spells/effects/HealTest.cpp @@ -348,10 +348,13 @@ TEST_P(HealApplyTest, Heals) const int32_t unitAmount = 24; const int32_t unitHP = 100; const uint32_t unitId = 42; + const auto pikeman = CreatureID(unitId).toCreature(); + auto & targetUnit = unitsFake.add(BattleSide::ATTACKER); EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount)); EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId)); + EXPECT_CALL(targetUnit, unitType()).WillRepeatedly(Return(pikeman)); targetUnit.addNewBonus(std::make_shared(Bonus::PERMANENT, Bonus::STACK_HEALTH, Bonus::CREATURE_ABILITY, unitHP, 0)); @@ -374,6 +377,17 @@ TEST_P(HealApplyTest, Heals) EXPECT_CALL(*battleFake, setUnitState(Eq(unitId), _, Gt(0))).Times(1); + //There should be battle log message if resurrect + switch(healLevel) + { + case EHealLevel::RESURRECT: + case EHealLevel::OVERHEAL: + EXPECT_CALL(serverMock, apply(Matcher(_))).Times(AtLeast(1)); + break; + default: + break; + } + EXPECT_CALL(serverMock, apply(Matcher(_))).Times(1); setupDefaultRNG(); diff --git a/test/spells/effects/SacrificeTest.cpp b/test/spells/effects/SacrificeTest.cpp index 770f017fd..f362377e1 100644 --- a/test/spells/effects/SacrificeTest.cpp +++ b/test/spells/effects/SacrificeTest.cpp @@ -166,12 +166,14 @@ TEST_F(SacrificeApplyTest, ResurrectsTarget) const uint32_t victimId = 4242; const int32_t victimCount = 5; const int32_t victimUnitHP = 100; + const auto pikeman = CreatureID(unitId).toCreature(); const int64_t expectedHealValue = (effectPower + victimUnitHP + effectValue) * victimCount; auto & targetUnit = unitsFake.add(BattleSide::ATTACKER); EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount)); EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId)); + EXPECT_CALL(targetUnit, unitType()).WillRepeatedly(Return(pikeman)); EXPECT_CALL(mechanicsMock, getEffectPower()).Times(AtLeast(1)).WillRepeatedly(Return(effectPower)); EXPECT_CALL(mechanicsMock, applySpellBonus(_, Eq(&targetUnit))).WillOnce(ReturnArg<0>()); @@ -201,6 +203,7 @@ TEST_F(SacrificeApplyTest, ResurrectsTarget) EXPECT_CALL(targetUnit, acquire()).WillOnce(Return(targetUnitState)); EXPECT_CALL(serverMock, apply(Matcher(_))).Times(AtLeast(1)); + EXPECT_CALL(serverMock, apply(Matcher(_))).Times(AtLeast(1)); setupDefaultRNG();