1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/*
* ERM_TM_T.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 <vcmi/events/GenericEvents.h>
#include "../scripting/ScriptFixture.h"
namespace test
{
namespace scripting
{
using namespace ::testing;
class ERM_TM_T : public Test, public ScriptFixture
{
public:
int day = 1;
protected:
void SetUp() override
{
ScriptFixture::setUp();
}
};
TEST_F(ERM_TM_T, NewGame)
{
loadScript(VLC->scriptHandler->erm,
{
"VERM",
"!#TM5:S2/10/3/2;",
"!#TM6:S2/20/3/3;",
"!?TM5;",
"!!VRv42: +1;",
"!?TM6;",
"!!VRv43: +1;"
});
SCOPED_TRACE("\n" + subject->code);
runClientServer();
day = 1;
auto getDate = [&](Date::EDateType mode)
{
return day;
};
EXPECT_CALL(infoMock, getDate(Eq(Date::DAY))).WillRepeatedly(Invoke(getDate));
auto onGetTurn = [](events::PlayerGotTurn & event)
{
};
for(; day < 25; day++)
{
events::TurnStarted::defaultExecute(&eventBus);
for(auto playerId = 0; playerId < 5; playerId++)
{
PlayerColor p(playerId);
::events::PlayerGotTurn::defaultExecute(&eventBus, onGetTurn, p);
}
}
const JsonNode actualState = context->saveState();
EXPECT_EQ(actualState["ERM"]["v"]["42"], JsonUtils::floatNode(3)) << actualState.toJson();
EXPECT_EQ(actualState["ERM"]["v"]["43"], JsonUtils::floatNode(14)) << actualState.toJson();
}
}
}
|