Ver Fonte

Introduce event test namespace

Patrick-Christopher Mattulat há 2 anos atrás
pai
commit
c70bf77596

+ 12 - 12
test/cases/event/EventManagerTest.cpp

@@ -39,7 +39,7 @@ namespace
                    try
                    {
                      ls::std::event::EventManager eventManager{};
-                     eventManager.subscribe("", std::make_shared<ls_std_test::DailyNewsAgency>());
+                     eventManager.subscribe("", std::make_shared<ls_std_event_test::DailyNewsAgency>());
                    }
                    catch (const ls::std::core::IllegalArgumentException &_exception)
                    {
@@ -69,7 +69,7 @@ namespace
                    try
                    {
                      ls::std::event::EventManager eventManager{};
-                     eventManager.subscribe("TMP_DIR", std::make_shared<ls_std_test::DailyNewsAgency>());
+                     eventManager.subscribe("TMP_DIR", std::make_shared<ls_std_event_test::DailyNewsAgency>());
                    }
                    catch (const ls::std::core::EventNotSubscribedException &_exception)
                    {
@@ -84,7 +84,7 @@ namespace
                    try
                    {
                      ls::std::event::EventManager eventManager{};
-                     eventManager.unsubscribe("", std::make_shared<ls_std_test::DailyNewsAgency>());
+                     eventManager.unsubscribe("", std::make_shared<ls_std_event_test::DailyNewsAgency>());
                    }
                    catch (const ls::std::core::IllegalArgumentException &_exception)
                    {
@@ -212,8 +212,8 @@ namespace
   TEST_F(EventManagerTest, production_example)
   {
     std::string news, expectedNews{};
-    ls::std::core::type::event_id seriousNewsEventId = ls_std_test::SeriousNewsEvent{""}.getId();
-    ls::std::core::type::event_id gossipNewsEventId = ls_std_test::GossipNewsEvent{""}.getId();
+    ls::std::core::type::event_id seriousNewsEventId = ls_std_event_test::SeriousNewsEvent{""}.getId();
+    ls::std::core::type::event_id gossipNewsEventId = ls_std_event_test::GossipNewsEvent{""}.getId();
 
     // create event handler
 
@@ -228,12 +228,12 @@ namespace
 
     // create news agency (listener)
 
-    std::shared_ptr<ls_std_test::DailyNewsAgency> dailyNews = std::make_shared<ls_std_test::DailyNewsAgency>();
-    std::shared_ptr<ls_std_test::GossipNewsAgency> gossipNews = std::make_shared<ls_std_test::GossipNewsAgency>();
+    std::shared_ptr<ls_std_event_test::DailyNewsAgency> dailyNews = std::make_shared<ls_std_event_test::DailyNewsAgency>();
+    std::shared_ptr<ls_std_event_test::GossipNewsAgency> gossipNews = std::make_shared<ls_std_event_test::GossipNewsAgency>();
 
     // fire SeriousNewsEvent event with no effect
 
-    eventManager->fire(ls_std_test::SeriousNewsEvent(news)); // event call
+    eventManager->fire(ls_std_event_test::SeriousNewsEvent(news)); // event call
     ASSERT_TRUE(dailyNews->getNews().empty());
     ASSERT_TRUE(gossipNews->getNews().empty());
 
@@ -242,7 +242,7 @@ namespace
     eventManager->subscribe(seriousNewsEventId, dailyNews);
     eventManager->subscribe(seriousNewsEventId, gossipNews);
     news = "COVID-19 is still going on!";
-    eventManager->fire(ls_std_test::SeriousNewsEvent(news)); // event call
+    eventManager->fire(ls_std_event_test::SeriousNewsEvent(news)); // event call
 
     expectedNews = "DailyNewsAgency: " + news;
     ASSERT_STREQ(expectedNews.c_str(), dailyNews->getNews().c_str());
@@ -255,7 +255,7 @@ namespace
     // unsubscribe SeriousNewsEvent from GossipNewsAgency
 
     eventManager->unsubscribe(seriousNewsEventId, gossipNews);
-    eventManager->fire(ls_std_test::SeriousNewsEvent(news)); // event call
+    eventManager->fire(ls_std_event_test::SeriousNewsEvent(news)); // event call
 
     expectedNews = "DailyNewsAgency: " + news;
     ASSERT_STREQ(expectedNews.c_str(), dailyNews->getNews().c_str());
@@ -270,12 +270,12 @@ namespace
     eventManager->subscribe(seriousNewsEventId, gossipNews);
 
     news = "COVID-19 is still going on!";
-    eventManager->fire(ls_std_test::SeriousNewsEvent(news)); // event call
+    eventManager->fire(ls_std_event_test::SeriousNewsEvent(news)); // event call
     expectedNews = "GossipNewsAgency: " + news;
     ASSERT_STREQ(expectedNews.c_str(), gossipNews->getNews().c_str());
 
     news = "ape likes banana!";
-    eventManager->fire(ls_std_test::GossipNewsEvent(news)); // event call
+    eventManager->fire(ls_std_event_test::GossipNewsEvent(news)); // event call
     expectedNews = "GossipNewsAgency: " + news;
     ASSERT_STREQ(expectedNews.c_str(), gossipNews->getNews().c_str());
   }

+ 6 - 6
test/cases/event/NarratorTest.cpp

@@ -27,17 +27,17 @@ namespace
       void TearDown() override
       {}
 
-      std::shared_ptr<ls_std_test::TestDataMercedesCar> mercedes1{};
-      std::shared_ptr<ls_std_test::TestDataMercedesCar> mercedes2{};
-      std::shared_ptr<ls_std_test::TestDataMercedesCar> mercedes3{};
+      std::shared_ptr<ls_std_event_test::TestDataMercedesCar> mercedes1{};
+      std::shared_ptr<ls_std_event_test::TestDataMercedesCar> mercedes2{};
+      std::shared_ptr<ls_std_event_test::TestDataMercedesCar> mercedes3{};
 
       void createCars()
       {
-        this->mercedes1 = std::make_shared<ls_std_test::TestDataMercedesCar>();
+        this->mercedes1 = std::make_shared<ls_std_event_test::TestDataMercedesCar>();
         this->mercedes1->setColor("pink");
-        this->mercedes2 = std::make_shared<ls_std_test::TestDataMercedesCar>();
+        this->mercedes2 = std::make_shared<ls_std_event_test::TestDataMercedesCar>();
         this->mercedes2->setColor("blue");
-        this->mercedes3 = std::make_shared<ls_std_test::TestDataMercedesCar>();
+        this->mercedes3 = std::make_shared<ls_std_event_test::TestDataMercedesCar>();
         this->mercedes3->setColor("red");
       }
   };

+ 4 - 4
test/classes/event/DailyNewsAgency.cpp

@@ -10,10 +10,10 @@
 #include "DailyNewsAgency.hpp"
 #include <ls_std/ls_std_event.hpp>
 
-ls_std_test::DailyNewsAgency::DailyNewsAgency() : ls_std_test::NewsAgency("DailyNewsAgency")
+ls_std_event_test::DailyNewsAgency::DailyNewsAgency() : ls_std_event_test::NewsAgency("DailyNewsAgency")
 {}
 
-void ls_std_test::DailyNewsAgency::listen(const ls::std::core::Class &_info)
+void ls_std_event_test::DailyNewsAgency::listen(const ls::std::core::Class &_info)
 {
   ls::std::event::Event event = dynamic_cast<const ls::std::event::Event &>(_info);
 
@@ -23,12 +23,12 @@ void ls_std_test::DailyNewsAgency::listen(const ls::std::core::Class &_info)
   }
 }
 
-void ls_std_test::DailyNewsAgency::clear()
+void ls_std_event_test::DailyNewsAgency::clear()
 {
   this->news.clear();
 }
 
-std::string ls_std_test::DailyNewsAgency::getNews()
+std::string ls_std_event_test::DailyNewsAgency::getNews()
 {
   return this->news;
 }

+ 2 - 2
test/classes/event/DailyNewsAgency.hpp

@@ -16,9 +16,9 @@
 #include <ls_std/ls_std_core.hpp>
 #include "NewsAgency.hpp"
 
-namespace ls_std_test // TODO: change namespace to event specific namespace
+namespace ls_std_event_test
 {
-  class DailyNewsAgency : public ls_std_test::NewsAgency, public ls::std::core::IListener
+  class DailyNewsAgency : public ls_std_event_test::NewsAgency, public ls::std::core::IListener
   {
     public:
 

+ 4 - 4
test/classes/event/GossipNewsAgency.cpp

@@ -10,10 +10,10 @@
 #include "GossipNewsAgency.hpp"
 #include <ls_std/ls_std_event.hpp>
 
-ls_std_test::GossipNewsAgency::GossipNewsAgency() : ls_std_test::NewsAgency("GossipNewsAgency")
+ls_std_event_test::GossipNewsAgency::GossipNewsAgency() : ls_std_event_test::NewsAgency("GossipNewsAgency")
 {}
 
-void ls_std_test::GossipNewsAgency::listen(const ls::std::core::Class &_info)
+void ls_std_event_test::GossipNewsAgency::listen(const ls::std::core::Class &_info)
 {
   ls::std::event::Event event = dynamic_cast<const ls::std::event::Event &>(_info);
 
@@ -28,12 +28,12 @@ void ls_std_test::GossipNewsAgency::listen(const ls::std::core::Class &_info)
   }
 }
 
-void ls_std_test::GossipNewsAgency::clear()
+void ls_std_event_test::GossipNewsAgency::clear()
 {
   this->news.clear();
 }
 
-std::string ls_std_test::GossipNewsAgency::getNews()
+std::string ls_std_event_test::GossipNewsAgency::getNews()
 {
   return this->news;
 }

+ 2 - 2
test/classes/event/GossipNewsAgency.hpp

@@ -16,9 +16,9 @@
 #include <ls_std/ls_std_core.hpp>
 #include "NewsAgency.hpp"
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
-  class GossipNewsAgency : public ls_std_test::NewsAgency, public ls::std::core::IListener
+  class GossipNewsAgency : public ls_std_event_test::NewsAgency, public ls::std::core::IListener
   {
     public:
 

+ 2 - 2
test/classes/event/GossipNewsEvent.cpp

@@ -3,13 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2022-05-12
+ * Changed:         2022-05-14
  *
  * */
 
 #include "GossipNewsEvent.hpp"
 
-ls_std_test::GossipNewsEvent::GossipNewsEvent(const std::string &_news) : ls::std::event::Event("GossipNewsEvent")
+ls_std_event_test::GossipNewsEvent::GossipNewsEvent(const std::string &_news) : ls::std::event::Event("GossipNewsEvent")
 {
   ls::std::core::type::event_parameter newsParameter = std::make_pair("news", _news);
   this->addParameter(newsParameter);

+ 1 - 1
test/classes/event/GossipNewsEvent.hpp

@@ -13,7 +13,7 @@
 #include <ls_std/ls_std_event.hpp>
 #include <string>
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
   class GossipNewsEvent : public ls::std::event::Event
   {

+ 3 - 3
test/classes/event/NewsAgency.cpp

@@ -3,16 +3,16 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2021-04-23
+ * Changed:         2022-05-14
  *
  * */
 
 #include "NewsAgency.hpp"
 
-ls_std_test::NewsAgency::NewsAgency(std::string _agencyName) : agencyName(std::move(_agencyName))
+ls_std_event_test::NewsAgency::NewsAgency(std::string _agencyName) : agencyName(std::move(_agencyName))
 {}
 
-std::string ls_std_test::NewsAgency::getName()
+std::string ls_std_event_test::NewsAgency::getName()
 {
   return this->agencyName;
 }

+ 1 - 1
test/classes/event/NewsAgency.hpp

@@ -12,7 +12,7 @@
 
 #include <string>
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
   class NewsAgency
   {

+ 2 - 2
test/classes/event/SeriousNewsEvent.cpp

@@ -3,13 +3,13 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-11-27
- * Changed:         2022-05-12
+ * Changed:         2022-05-14
  *
  * */
 
 #include "SeriousNewsEvent.hpp"
 
-ls_std_test::SeriousNewsEvent::SeriousNewsEvent(const std::string &_news) : ls::std::event::Event("SeriousNewsEvent")
+ls_std_event_test::SeriousNewsEvent::SeriousNewsEvent(const std::string &_news) : ls::std::event::Event("SeriousNewsEvent")
 {
   ls::std::core::type::event_parameter newsParameter = std::make_pair("news", _news);
   this->addParameter(newsParameter);

+ 1 - 1
test/classes/event/SeriousNewsEvent.hpp

@@ -13,7 +13,7 @@
 #include <ls_std/ls_std_event.hpp>
 #include <string>
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
   class SeriousNewsEvent : public ls::std::event::Event
   {

+ 3 - 3
test/classes/event/TestDataCar.cpp

@@ -9,15 +9,15 @@
 
 #include "TestDataCar.hpp"
 
-ls_std_test::TestDataCar::TestDataCar() : color("white")
+ls_std_event_test::TestDataCar::TestDataCar() : color("white")
 {}
 
-std::string ls_std_test::TestDataCar::getColor()
+std::string ls_std_event_test::TestDataCar::getColor()
 {
   return this->color;
 }
 
-void ls_std_test::TestDataCar::setColor(std::string _color)
+void ls_std_event_test::TestDataCar::setColor(std::string _color)
 {
   this->color = std::move(_color);
 }

+ 1 - 1
test/classes/event/TestDataCar.hpp

@@ -12,7 +12,7 @@
 
 #include <string>
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
   class TestDataCar
   {

+ 2 - 2
test/classes/event/TestDataMercedesCar.cpp

@@ -10,12 +10,12 @@
 #include "Colour.hpp"
 #include "TestDataMercedesCar.hpp"
 
-ls_std_test::TestDataMercedesCar::TestDataMercedesCar() : TestDataCar()
+ls_std_event_test::TestDataMercedesCar::TestDataMercedesCar() : TestDataCar()
 {
   this->setColor("blue");
 }
 
-void ls_std_test::TestDataMercedesCar::listen(const ls::std::core::Class &_info)
+void ls_std_event_test::TestDataMercedesCar::listen(const ls::std::core::Class &_info)
 {
   this->setColor(dynamic_cast<const ls_std_event_test::Colour &>(_info).getValue());
 }

+ 2 - 2
test/classes/event/TestDataMercedesCar.hpp

@@ -14,9 +14,9 @@
 #include "ls_std/core/interface/IListener.hpp"
 #include "ls_std/core/Class.hpp"
 
-namespace ls_std_test
+namespace ls_std_event_test
 {
-  class TestDataMercedesCar : public TestDataCar, public ls::std::core::IListener
+  class TestDataMercedesCar : public ls_std_event_test::TestDataCar, public ls::std::core::IListener
   {
     public: