/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2024-05-16 * Changed: 2024-05-17 * * */ #include #include #include 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").of(make_shared()); 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").of(nullptr); } catch (const IllegalArgumentException &_exception) { throw; } }, IllegalArgumentException); } TEST_F(EventTest, setManager) { auto event = Event("TmpEvent"); ASSERT_TRUE(event.getManager() == nullptr); event.setManager(make_shared()); 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); } }