mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-18 17:40:48 +02:00
8724181a0f
Now instead of XXX_IMMUNITY bonuses we have 2 bonuses with spellSchool subtype: SPELL_SCHOOL_IMMUNITY and NEGATIVE_EFFECT_IMMUNITY. All previous bonuses of subtype 0 is covered by SPELL_SCHOOL_IMMUNITY, and all previous bonuses of subtype 1 is covered by NEGATIVE_EFFECT_IMMUNITY. Unit tests are updated accordingly.
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
/*
|
|
* BonusConditionTest.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 "TargetConditionItemFixture.h"
|
|
|
|
namespace test
|
|
{
|
|
using namespace ::spells;
|
|
using namespace ::testing;
|
|
|
|
class BonusConditionTest : public TargetConditionItemTest
|
|
{
|
|
public:
|
|
void setDefaultExpectations()
|
|
{
|
|
EXPECT_CALL(unitMock, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
|
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
|
}
|
|
|
|
void SetUp() override
|
|
{
|
|
TargetConditionItemTest::SetUp();
|
|
subject = TargetConditionItemFactory::getDefault()->createConfigurable("", "bonus", "DIRECT_DAMAGE_IMMUNITY");
|
|
GTEST_ASSERT_NE(subject, nullptr);
|
|
}
|
|
};
|
|
|
|
TEST_F(BonusConditionTest, ImmuneByDefault)
|
|
{
|
|
setDefaultExpectations();
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
}
|
|
|
|
TEST_F(BonusConditionTest, ReceptiveIfMatchesType)
|
|
{
|
|
setDefaultExpectations();
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_DAMAGE_REDUCTION, BonusSource::OTHER, 100, 0));
|
|
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
}
|
|
|
|
TEST_F(BonusConditionTest, ImmuneIfTypeMismatch)
|
|
{
|
|
setDefaultExpectations();
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::OTHER, 0, SpellSchool(ESpellSchool::FIRE)));
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
}
|
|
|
|
}
|