2017-07-20 06:08:49 +02:00
|
|
|
/*
|
|
|
|
* 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();
|
2023-10-21 13:50:42 +02:00
|
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_DAMAGE_REDUCTION, BonusSource::OTHER, 100, BonusSourceID()));
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BonusConditionTest, ImmuneIfTypeMismatch)
|
|
|
|
{
|
|
|
|
setDefaultExpectations();
|
2023-10-21 13:50:42 +02:00
|
|
|
unitBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::SPELL_SCHOOL_IMMUNITY, BonusSource::OTHER, 0, BonusSourceID(), BonusSubtypeID(SpellSchool::FIRE)));
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_FALSE(subject->isReceptive(&mechanicsMock, &unitMock));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|