mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-28 23:06:24 +02:00
tests: add ResistanceCondition test
This commit is contained in:
parent
3d46ee3182
commit
75948a5dd7
@ -67,6 +67,7 @@ set(test_SRCS
|
||||
spells/targetConditions/NormalLevelConditionTest.cpp
|
||||
spells/targetConditions/NormalSpellConditionTest.cpp
|
||||
spells/targetConditions/ReceptiveFeatureConditionTest.cpp
|
||||
spells/targetConditions/ResistanceConditionTest.cpp
|
||||
spells/targetConditions/SpellEffectConditionTest.cpp
|
||||
spells/targetConditions/TargetConditionItemFixture.cpp
|
||||
|
||||
|
@ -33,6 +33,9 @@ public:
|
||||
MOCK_CONST_METHOD0(manaLimit, int32_t());
|
||||
MOCK_CONST_METHOD0(getHeroCaster, CGHeroInstance*());
|
||||
|
||||
//ACreature
|
||||
MOCK_CONST_METHOD0(magicResistance, int32_t());
|
||||
|
||||
MOCK_CONST_METHOD0(unitBaseAmount, int32_t());
|
||||
MOCK_CONST_METHOD0(unitId, uint32_t());
|
||||
MOCK_CONST_METHOD0(unitSide, ui8());
|
||||
|
72
test/spells/targetConditions/ResistanceConditionTest.cpp
Normal file
72
test/spells/targetConditions/ResistanceConditionTest.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* ElementalConditionTest.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 ResistanceConditionTest : public TargetConditionItemTest, public WithParamInterface<bool>
|
||||
{
|
||||
public:
|
||||
bool isPositive;
|
||||
void setDefaultExpectations()
|
||||
{
|
||||
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
||||
EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
TargetConditionItemTest::SetUp();
|
||||
subject = TargetConditionItemFactory::getDefault()->createResistance();
|
||||
|
||||
isPositive = GetParam();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ResistanceConditionTest, ReceptiveIfNoBonus)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
EXPECT_CALL(unitMock, magicResistance()).Times(AtLeast(0)).WillRepeatedly(Return(0));
|
||||
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
TEST_P(ResistanceConditionTest, DependsOnPositivness)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
EXPECT_CALL(unitMock, magicResistance()).Times(AtLeast(0)).WillRepeatedly(Return(100));
|
||||
|
||||
EXPECT_EQ(isPositive, subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
TEST_P(ResistanceConditionTest, ReceptiveIfResistanceIsLessThanHundred)
|
||||
{
|
||||
setDefaultExpectations();
|
||||
|
||||
EXPECT_CALL(unitMock, magicResistance()).Times(AtLeast(0)).WillRepeatedly(Return(99));
|
||||
|
||||
EXPECT_TRUE(subject->isReceptive(&mechanicsMock, &unitMock));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P
|
||||
(
|
||||
ByPositiveness,
|
||||
ResistanceConditionTest,
|
||||
Values(false, true)
|
||||
);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user