ERM_TM_T.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * ERM_TM_T.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include <vcmi/events/GenericEvents.h>
  12. #include "../scripting/ScriptFixture.h"
  13. namespace test
  14. {
  15. namespace scripting
  16. {
  17. using namespace ::testing;
  18. class ERM_TM_T : public Test, public ScriptFixture
  19. {
  20. public:
  21. int day = 1;
  22. protected:
  23. void SetUp() override
  24. {
  25. ScriptFixture::setUp();
  26. }
  27. };
  28. TEST_F(ERM_TM_T, NewGame)
  29. {
  30. loadScript(VLC->scriptHandler->erm,
  31. {
  32. "VERM",
  33. "!#TM5:S2/10/3/2;",
  34. "!#TM6:S2/20/3/3;",
  35. "!?TM5;",
  36. "!!VRv42: +1;",
  37. "!?TM6;",
  38. "!!VRv43: +1;"
  39. });
  40. SCOPED_TRACE("\n" + subject->code);
  41. runClientServer();
  42. day = 1;
  43. auto getDate = [&](Date::EDateType mode)
  44. {
  45. return day;
  46. };
  47. EXPECT_CALL(infoMock, getDate(Eq(Date::DAY))).WillRepeatedly(Invoke(getDate));
  48. auto onGetTurn = [](events::PlayerGotTurn & event)
  49. {
  50. };
  51. for(; day < 25; day++)
  52. {
  53. events::TurnStarted::defaultExecute(&eventBus);
  54. for(auto playerId = 0; playerId < 5; playerId++)
  55. {
  56. PlayerColor p(playerId);
  57. ::events::PlayerGotTurn::defaultExecute(&eventBus, onGetTurn, p);
  58. }
  59. }
  60. const JsonNode actualState = context->saveState();
  61. EXPECT_EQ(actualState["ERM"]["v"]["42"], JsonUtils::floatNode(3)) << actualState.toJson();
  62. EXPECT_EQ(actualState["ERM"]["v"]["43"], JsonUtils::floatNode(14)) << actualState.toJson();
  63. }
  64. }
  65. }