123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2024-05-16
- * Changed: 2024-05-30
- *
- * */
- #include <gtest/gtest.h>
- #include <ls-std/ls-std-core.hpp>
- #include <ls-std/ls-std-event.hpp>
- using ls::std::core::IllegalArgumentException;
- using ls::std::event::Event;
- using ls::std::event::EventManager;
- using ::std::make_shared;
- using testing::Test;
- namespace
- {
- class EventTest : public Test
- {
- public:
- EventTest() = default;
- ~EventTest() override = default;
- };
- TEST_F(EventTest, getClassName)
- {
- ASSERT_STREQ("OnClickEvent", Event("OnClickEvent").getClassName().c_str());
- }
- TEST_F(EventTest, getManager)
- {
- ASSERT_TRUE(Event("TmpEvent").getManager() == nullptr);
- }
- TEST_F(EventTest, of)
- {
- auto event = Event("TmpEvent").supervisedBy(make_shared<EventManager>());
- ASSERT_STREQ("TmpEvent", event.getClassName().c_str());
- ASSERT_TRUE(event.getManager() != nullptr);
- }
- TEST_F(EventTest, of_with_no_reference)
- {
- EXPECT_THROW(
- {
- try
- {
- auto event = Event("TmpEvent").supervisedBy(nullptr);
- }
- catch (const IllegalArgumentException &_exception)
- {
- throw;
- }
- },
- IllegalArgumentException);
- }
- TEST_F(EventTest, setManager)
- {
- auto event = Event("TmpEvent");
- ASSERT_TRUE(event.getManager() == nullptr);
- event.setManager(make_shared<EventManager>());
- ASSERT_FALSE(event.getManager() == nullptr);
- }
- TEST_F(EventTest, setManager_with_no_reference)
- {
- auto event = Event("TmpEvent");
- EXPECT_THROW(
- {
- try
- {
- event.setManager(nullptr);
- }
- catch (const IllegalArgumentException &_exception)
- {
- throw;
- }
- },
- IllegalArgumentException);
- }
- }
|