TeleportTest.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * TeleportTest.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 "EffectFixture.h"
  12. #include <vstd/RNG.h>
  13. namespace test
  14. {
  15. using namespace ::spells;
  16. using namespace ::spells::effects;
  17. using namespace ::testing;
  18. class TeleportTest : public Test, public EffectFixture
  19. {
  20. public:
  21. TeleportTest()
  22. : EffectFixture("core:teleport")
  23. {
  24. }
  25. protected:
  26. void SetUp() override
  27. {
  28. EffectFixture::setUp();
  29. setupEffect(JsonNode());
  30. }
  31. };
  32. class TeleportApplyTest : public Test, public EffectFixture
  33. {
  34. public:
  35. TeleportApplyTest()
  36. : EffectFixture("core:teleport")
  37. {
  38. }
  39. protected:
  40. void SetUp() override
  41. {
  42. EffectFixture::setUp();
  43. setupEffect(JsonNode());
  44. }
  45. };
  46. TEST_F(TeleportApplyTest, DISABLED_MovesUnit)
  47. {
  48. battleFake->setupEmptyBattlefield();
  49. uint32_t unitId = 42;
  50. BattleHex initial(1, 1);
  51. BattleHex destination(10, 10);
  52. EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(0));
  53. auto & unit = unitsFake.add(BattleSide::ATTACKER);
  54. EXPECT_CALL(unit, getPosition()).WillRepeatedly(Return(initial));
  55. EXPECT_CALL(unit, unitId()).Times(AtLeast(1)).WillRepeatedly(Return(unitId));
  56. EXPECT_CALL(unit, doubleWide()).WillRepeatedly(Return(false));
  57. EXPECT_CALL(unit, isValidTarget(Eq(false))).WillRepeatedly(Return(true));
  58. EXPECT_CALL(*battleFake, moveUnit(Eq(unitId), Eq(destination)));
  59. EXPECT_CALL(mechanicsMock, getEffectLevel()).WillRepeatedly(Return(0));
  60. EXPECT_CALL(serverMock, apply(Matcher<BattleStackMoved *>(_))).Times(1);
  61. Target target;
  62. target.emplace_back(&unit, BattleHex());
  63. target.emplace_back(destination);
  64. subject->apply(&serverMock, &mechanicsMock, target);
  65. }
  66. }