EventTest.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-26
  6. * Changed: 2020-11-26
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls_std/ls_std.hpp>
  11. namespace {
  12. class EventTest : public ::testing::Test {
  13. protected:
  14. EventTest() = default;
  15. ~EventTest() override = default;
  16. void SetUp() override
  17. {}
  18. void TearDown() override
  19. {}
  20. };
  21. TEST_F(EventTest, getClassName)
  22. {
  23. ls_std::Event event {"OPEN_DOOR_EVENT"};
  24. ASSERT_STREQ("Event", event.getClassName().c_str());
  25. }
  26. TEST_F(EventTest, addParameter)
  27. {
  28. ls_std::Event event {"OPEN_DOOR_EVENT"};
  29. ASSERT_TRUE(event.getParameterList().empty());
  30. event.addParameter(ls_std::event_parameter("key", "yes"));
  31. event.addParameter(ls_std::event_parameter("facing_door", "yes"));
  32. ls_std::event_parameter_list parameterList = event.getParameterList();
  33. ASSERT_FALSE(parameterList.empty());
  34. ASSERT_EQ(2, parameterList.size());
  35. ASSERT_STREQ("yes", parameterList.at("key").c_str());
  36. ASSERT_STREQ("yes", parameterList.at("facing_door").c_str());
  37. }
  38. TEST_F(EventTest, getId)
  39. {
  40. ls_std::Event event {"OPEN_DOOR_EVENT"};
  41. ASSERT_STREQ("OPEN_DOOR_EVENT", event.getId().c_str());
  42. }
  43. TEST_F(EventTest, getParameterList)
  44. {
  45. ls_std::Event event {"OPEN_DOOR_EVENT"};
  46. ASSERT_TRUE(event.getParameterList().empty());
  47. }
  48. TEST_F(EventTest, removeParameter)
  49. {
  50. ls_std::Event event {"OPEN_DOOR_EVENT"};
  51. ASSERT_TRUE(event.getParameterList().empty());
  52. event.addParameter(ls_std::event_parameter("key", "yes"));
  53. event.addParameter(ls_std::event_parameter("facing_door", "yes"));
  54. ASSERT_FALSE(event.getParameterList().empty());
  55. ASSERT_EQ(2, event.getParameterList().size());
  56. event.removeParameter("key");
  57. ASSERT_EQ(1, event.getParameterList().size());
  58. event.removeParameter("facing_door");
  59. ASSERT_EQ(0, event.getParameterList().size());
  60. ASSERT_TRUE(event.getParameterList().empty());
  61. }
  62. }