2017-07-20 06:08:49 +02:00
|
|
|
/*
|
|
|
|
* SpellEffectConditionTest.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "TargetConditionItemFixture.h"
|
|
|
|
|
|
|
|
namespace test
|
|
|
|
{
|
|
|
|
using namespace ::spells;
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
|
|
class SpellEffectConditionTest : public TargetConditionItemTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void setDefaultExpectations()
|
|
|
|
{
|
|
|
|
EXPECT_CALL(unitMock, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
|
|
|
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
TargetConditionItemTest::SetUp();
|
|
|
|
|
2023-04-26 21:56:50 +02:00
|
|
|
subject = TargetConditionItemFactory::getDefault()->createConfigurable("core", "spell", "age");
|
2017-07-20 06:08:49 +02:00
|
|
|
GTEST_ASSERT_NE(subject, nullptr);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(SpellEffectConditionTest, ImmuneByDefault)
|
|
|
|
{
|
|
|
|
setDefaultExpectations();
|
|
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SpellEffectConditionTest, ReceptiveIfHasEffectFromDesiredSpell)
|
|
|
|
{
|
|
|
|
setDefaultExpectations();
|
2023-10-10 17:05:18 +02:00
|
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(SpellID(SpellID::AGE))));
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SpellEffectConditionTest, ImmuneIfHasEffectFromOtherSpell)
|
|
|
|
{
|
|
|
|
setDefaultExpectations();
|
2023-10-10 17:05:18 +02:00
|
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::SPELL_EFFECT, 3, TBonusSourceID(SpellID(SpellID::AIR_SHIELD))));
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SpellEffectConditionTest, ImmuneIfHasNoSpellEffects)
|
|
|
|
{
|
|
|
|
setDefaultExpectations();
|
2023-10-14 17:13:59 +02:00
|
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 3, TBonusSourceID()));
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|